ソースコード
with r22 as (
    select
        H.area_code 'CODE'
        ,(round(100*cast(food_exp as real)/cast(consumption_exp as real), 1) || '%') as '2022_RATIO'
    from
        household_survey H
        left join area A on A.area_code=H.area_code
    where
        survey_year = 2022
)

,r17 as (
    select
        H.area_code 'CODE'
        ,(round(100*cast(food_exp as real)/cast(consumption_exp as real), 1) || '%') as '2017_RATIO'
    from
        household_survey H
        left join area A on A.area_code=H.area_code
    where
        survey_year = 2017
)

,r12 as (
    select
        H.area_code 'CODE'
        ,(round(100*cast(food_exp as real)/cast(consumption_exp as real), 1) || '%') as '2012_RATIO'
    from
        household_survey H
        left join area A on A.area_code=H.area_code
    where
        survey_year = 2012
)

select
    A.area_code 'CODE'
    ,area_name 'NAME'
    ,dense_rank() over (order by r22.'2022_RATIO' asc) '2022_RANK'
    ,r22.'2022_RATIO'
    ,dense_rank() over (order by r17.'2017_RATIO' asc) '2017_RANK'
    ,r17.'2017_RATIO'
    ,dense_rank() over (order by r12.'2012_RATIO' asc) '2012_RANK'
    ,r12.'2012_RATIO'
from
    area A
    left join r22 on r22.CODE=A.area_code
    left join r17 on r17.CODE=A.area_code
    left join r12 on r12.CODE=A.area_code
order by
    '2022_RANK' asc
    ,'CODE' desc
提出情報
提出日時2023/12/18 00:59:32
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者kntnmn
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
86 MB
データパターン2
WA
85 MB
データパターン3
WA
85 MB