ソースコード
select
    A.AREA_CODE AS CODE
    , A.AREA_NAME AS NAME
    , dense_rank() over(order by Y22.RAITO asc) as "2022_RANK"
    , Y22.RAITO || '%' as "2022_RATIO"
    , dense_rank() over(order by Y17.RAITO asc) as "2017_RANK"
    , Y17.RAITO || '%' as "2017_RATIO"
    , dense_rank() over(order by Y12.RAITO asc) as "2012_RANK"
    , Y12.RAITO || '%' as "2012_RATIO"
from AREA as A
    inner join (select
                    AREA_CODE
                    , round((cast(FOOD_EXP as real)/CONSUMPTION_EXP)*100,1) AS RAITO
                from HOUSEHOLD_SURVEY
                where SURVEY_YEAR=2022
                group by AREA_CODE
                ) as Y22 on A.AREA_CODE=Y22.AREA_CODE
    inner join (select
                    AREA_CODE
                    , round((cast(FOOD_EXP as real)/CONSUMPTION_EXP)*100,1) AS RAITO
                from HOUSEHOLD_SURVEY
                where SURVEY_YEAR=2017
                group by AREA_CODE
                ) as Y17 on A.AREA_CODE=Y17.AREA_CODE
    inner join (select
                    AREA_CODE
                    , round((cast(FOOD_EXP as real)/CONSUMPTION_EXP)*100,1) AS RAITO
                from HOUSEHOLD_SURVEY
                where SURVEY_YEAR=2012
                group by AREA_CODE
                ) as Y12 on A.AREA_CODE=Y12.AREA_CODE
order by "2022_RANK" asc, code desc;
提出情報
提出日時2024/06/30 21:45:50
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者poapoa1010
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
85 MB
データパターン3
AC
85 MB