ソースコード
with tbl1 as (
    select *
        ,round(cast(FOOD_EXP as real) / cast(CONSUMPTION_EXP as real) * 100,1) || '%' as RATIO
    from HOUSEHOLD_SURVEY
    left join AREA
    on HOUSEHOLD_SURVEY.AREA_CODE = AREA.AREA_CODE
)
, tbl2022 as (
    select *
    from tbl1
    where SURVEY_YEAR = 2022
)
, tbl2017 as (
    select *
    from tbl1
    where SURVEY_YEAR = 2017
)
, tbl2012 as (
    select *
    from tbl1
    where SURVEY_YEAR = 2012
)
select 
    tbl2022.AREA_CODE as CODE
    ,tbl2022.AREA_NAME as NAME
    ,RANK () OVER (ORDER BY tbl2022.RATIO) as "2022_RANK"
    ,tbl2022.RATIO as "2022_RATIO"
    ,RANK ( ) OVER ( ORDER BY tbl2017.RATIO) as "2017_RANK"
    ,tbl2017.RATIO as "2017_RATIO"
    ,RANK ( ) OVER ( ORDER BY tbl2012.RATIO) as "2012_RANK"
    ,tbl2012.RATIO as "2012_RATIO"
from tbl2022
    left join tbl2017
    on tbl2022.AREA_CODE = tbl2017.AREA_CODE
    left join tbl2012
    on tbl2022.AREA_CODE = tbl2012.AREA_CODE
order by 
    "2022_RANK"
    ,tbl2022.AREA_CODE desc
提出情報
提出日時2023/12/15 15:53:33
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者sato
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量93 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
93 MB
データパターン2
WA
85 MB
データパターン3
WA
92 MB