ソースコード
with
    yoko as (
        select
            pf_code
            ,sum(case when kind_code = 100 then total_value end) as sales
            ,sum(case when kind_code = 150 then total_value end) as shops
        from
            convenience
        where
            survey_year = 2019
        group by
            1
        order by
            2 desc, 3 asc, 1 asc
    )
    ,rank as (
        select
            (row_number() over() + 2) / 3 as rank
            ,pf_code
            ,sales
            ,shops
        from
            yoko
    )
    ,ttl as (
        select
            rank
            ,sum(sales) as sales
            ,sum(shops) as shops
        from
            rank
        group by
            1
        order by
            1
    )

select
    rank
    ,sales as TTL_SAL
    ,round(cast(sales as real) * 100 / cast(sum(sales) over() as real), 1) as PER_SAL
    ,round(cast(sum(sales) over(order by rank) as real) * 100 / cast(sum(sales) over() as real), 1) as CUM_SAL
    ,cast(cast(sales as real) / cast(shops as real) as int) as AVG_SAL
from
    ttl
group by
    1
order by
    1
提出情報
提出日時2023/10/13 18:14:30
コンテスト第9回 SQLコンテスト
問題販売額分析
受験者takahirostone
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量90 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
90 MB
データパターン2
WA
79 MB
データパターン3
WA
79 MB