ソースコード
SELECT CODE, NAME,
    dense_rank() over (order by s1_RATIO) as '2022_RANK',
    s1_RATIO || '%' AS '2022_RATIO',
    dense_rank() over (order by s2_RATIO) as '2017_RANK',
    s2_RATIO || '%' AS '2017_RATIO',
    dense_rank() over (order by s3_RATIO) as '2012_RANK',
    s3_RATIO || '%' AS '2012_RATIO'
FROM (SELECT
        a.AREA_CODE AS CODE,
        a.AREA_NAME AS NAME,
        round((s1.FOOD_EXP*1.0 / s1.CONSUMPTION_EXP*1.0) *100, 1) AS s1_RATIO,
        round((s2.FOOD_EXP*1.0 / s2.CONSUMPTION_EXP*1.0) *100, 1) AS s2_RATIO,
        round((s3.FOOD_EXP*1.0 / s3.CONSUMPTION_EXP*1.0) *100, 1)AS s3_RATIO
    FROM AREA AS a
    JOIN (
        SELECT * FROM HOUSEHOLD_SURVEY WHERE SURVEY_YEAR = 2022
    ) AS s1 ON s1.AREA_CODE = a.AREA_CODE
    JOIN (
        SELECT * FROM HOUSEHOLD_SURVEY WHERE SURVEY_YEAR = 2017
    ) AS s2 ON s2.AREA_CODE = a.AREA_CODE
    JOIN (
        SELECT * FROM HOUSEHOLD_SURVEY WHERE SURVEY_YEAR = 2012
    ) AS s3 ON s3.AREA_CODE = a.AREA_CODE
)
ORDER BY s1_RATIO, CODE DESC 
提出情報
提出日時2024/02/18 16:43:35
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者oribe
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
86 MB
データパターン3
AC
85 MB