ソースコード
with r20 as 
(SELECT AREA_CODE CODE,
round(1.0 * FOOD_EXP / CONSUMPTION_EXP * 100.0,1) RANK22
FROM HOUSEHOLD_SURVEY
where 
SURVEY_YEAR ='2022'
),
r17 as 
(SELECT AREA_CODE CODE,
round(1.0 * FOOD_EXP / CONSUMPTION_EXP * 100.0,1) RANK17
FROM HOUSEHOLD_SURVEY
where 
SURVEY_YEAR ='2017'
) ,
 r12 as 
(SELECT AREA_CODE CODE,
round(1.0 * FOOD_EXP / CONSUMPTION_EXP * 100.0,1) RANK12
FROM HOUSEHOLD_SURVEY
where 
SURVEY_YEAR ='2012'
) 
select  r20.CODE
        ,AREA_NAME NAME
        ,DENSE_RANK() over(order by RANK22) as "2022_RANK"
        ,RANK22 || '%' as "2022_RATIO"
        ,DENSE_RANK() over(order by RANK17) as "2017_RANK"
        ,RANK17 || '%' as "2017_RATIO"
        ,DENSE_RANK() over(order by RANK12) as "2012_RANK"
        ,RANK12 || '%' as "2012_RATIO"
        from r20
join r17 on r20.CODE=r17.CODE
join r12 on r20.CODE=r12.CODE
left join AREA on r20.CODE=AREA.AREA_CODE
ORDER BY 3,1 desc
提出情報
提出日時2023/12/18 11:42:43
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者testmori2222222666
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量100 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
100 MB
データパターン2
AC
98 MB
データパターン3
AC
85 MB