ソースコード
WITH H22 AS
        (SELECT AREA_CODE, ROUND(100.0*FOOD_EXP/CONSUMPTION_EXP,2) PAR
        FROM HOUSEHOLD_SURVEY
        WHERE SURVEY_YEAR = 2022)
    , H17 AS
        (SELECT AREA_CODE, ROUND(100.0*FOOD_EXP/CONSUMPTION_EXP,2) PAR
        FROM HOUSEHOLD_SURVEY
        WHERE SURVEY_YEAR = 2017)
    , H12 AS
        (SELECT AREA_CODE, ROUND(100.0*FOOD_EXP/CONSUMPTION_EXP,2) PAR
        FROM HOUSEHOLD_SURVEY
        WHERE SURVEY_YEAR = 2012)
    
SELECT
H22.AREA_CODE CODE,
AREA.AREA_NAME NAME,
DENSE_RANK() OVER(ORDER BY H22.PAR) AS '2022_RANK',
H22.PAR || '%' AS "2022_RATIO",
DENSE_RANK() OVER(ORDER BY H17.PAR) AS '2017_RANK',
H17.PAR||'%' "2017_RATIO",
DENSE_RANK() OVER(ORDER BY H12.PAR) AS '2012_RANK',
H17.PAR||'%' "2012_RATIO"
FROM HOUSEHOLD_SURVEY HS JOIN AREA ON HS.AREA_CODE = AREA.AREA_CODE
JOIN H22 ON HS.AREA_CODE = H22.AREA_CODE
JOIN H17 ON HS.AREA_CODE = H17.AREA_CODE
JOIN H12 ON HS.AREA_CODE = H12.AREA_CODE
ORDER BY 3,1 DESC
提出情報
提出日時2024/07/19 13:54:32
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者0014
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
84 MB
データパターン2
WA
83 MB
データパターン3
WA
88 MB