ソースコード
with x as (
    select (rank() over(
        order by w.total_value desc,
        z.total_value asc,
        w.pf_code asc
    ) -1)/3 as r, 
    w.total_value as a, z.total_value as b from convenience as w
    inner join (
        select * from convenience
        where survey_year=2019 and kind_code=150
    ) as z
    on z.pf_code=w.pf_code
    where w.survey_year=2019 and w.kind_code=100
    order by 1
),
y as (
    select r+1 as 'NO', sum(a) as 'TTL_SAL', sum(a)/sum(b) as 'AVG_SAL' from x
    group by r
),
z as (
    select sum(total_value) from convenience
    where survey_year=2019 and kind_code=100
)
select p.NO, p.TTL_SAL, round(p.TTL_SAL*100.0/(select * from z),1)
as 'PER_SAL',
round(sum(q.TTL_SAL)*100.0/(select * from z),1) as 'CUM_SAL', p.AVG_SAL
from y as p
cross join y as q
on p.NO >= q.NO
group by 1
提出情報
提出日時2023/10/15 16:25:55
コンテスト第9回 SQLコンテスト
問題販売額分析
受験者tabr
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量83 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
78 MB
データパターン2
AC
78 MB
データパターン3
AC
83 MB