ソースコード
with sa as (
    select 
        row_number() over(order by sum(total_value) desc) as ranking,
        pf_code,
        sum(total_value) as sales,
        sum(total_value) over() as sumtotal
    from convenience
    where survey_year='2019' and kind_code='100'
    group by pf_code
),
cnt as (
    select 
        pf_code,
        sum(total_value) as count
    from convenience
    where survey_year='2019' and kind_code='150'
    group by pf_code
),
sumtbl as (
    select
        ranking,
        sa.pf_code as code,
        sales,
        count,
        sum(sales) over(order by ranking rows 2 preceding) as TTL_SAL,
        sum(sales) over(order by ranking) as subtotal,
        sumtotal,
        sum(count) over(order by ranking rows 2 preceding) as gsum_shop
    from sa
    inner join cnt
    on sa.pf_code=cnt.pf_code
    order by sales desc,count,code
)
select 
    ranking/3 as NO,
    TTL_SAL,
    round(cast(TTL_SAL as real)/cast(sumtotal as real)*100,1) as PER_SAL,
    round(cast(subtotal as real)/cast(sumtotal as real)*100,1) as CUM_SAL,
    cast(TTL_SAL/gsum_shop as int) as AVG_SAL
from sumtbl
where ranking%3=0
order by NO;


提出情報
提出日時2024/06/23 21:06:18
コンテスト第9回 SQLコンテスト
問題販売額分析
受験者kate
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
2/3
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
86 MB
データパターン3
WA
84 MB