ソースコード
WITH Pre AS(
SELECT
    H.AREA_CODE AS CODE,
    A.AREA_NAME AS NAME,
    ROUND(
        100.0 * 	
                SUM(CASE WHEN H.SURVEY_YEAR = 2022 THEN FOOD_EXP END)
			 / 
				SUM(CASE WHEN H.SURVEY_YEAR = 2022 THEN CONSUMPTION_EXP END),
		1) AS Per_2022,
	ROUND(
        100.0 * 	
                SUM(CASE WHEN H.SURVEY_YEAR = 2017 THEN FOOD_EXP END)
			 / 
				SUM(CASE WHEN H.SURVEY_YEAR = 2017 THEN CONSUMPTION_EXP END),
		1) AS Per_2017,
	ROUND(
        100.0 * 	
                SUM(CASE WHEN H.SURVEY_YEAR = 2012 THEN FOOD_EXP END)
			 / 
				SUM(CASE WHEN H.SURVEY_YEAR = 2012 THEN CONSUMPTION_EXP END),
		1) AS Per_2012
FROM
    HOUSEHOLD_SURVEY AS H
JOIN
    AREA AS A
ON
    H.AREA_CODE = A.AREA_CODE
GROUP BY
    CODE
)
SELECT
    CODE,
    NAME,
    DENSE_RANK() OVER(ORDER BY Per_2022 ASC) AS '2022_RANK',
    Per_2022 || '%' AS '2022_RATIO',
    DENSE_RANK() OVER(ORDER BY Per_2017 ASC) AS '2017_RANK',
    Per_2017 || '%' AS '2017_RATIO',
    DENSE_RANK() OVER(ORDER BY Per_2012 ASC) AS '2012_RANK',
    Per_2012 || '%' AS '2012_RATIO'
FROM
    Pre
GROUP BY
    CODE
ORDER BY
    Per_2022 ASC,
    CODE DESC
LIMIT
    5
提出情報
提出日時2023/12/17 15:46:27
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者north_mb_p
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量93 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
91 MB
データパターン2
WA
93 MB
データパターン3
WA
85 MB