ソースコード
WITH A AS (
	SELECT
		AREA_CODE
		,ROUND((FOOD_EXP*1.00/CONSUMPTION_EXP*1.00)*100,1) RATIO
		,DENSE_RANK() OVER (ORDER BY ROUND((FOOD_EXP*1.00/CONSUMPTION_EXP*1.00)*100,1)) RANK
	FROM
		HOUSEHOLD_SURVEY
	WHERE
		SURVEY_YEAR = 2022
)
, B AS (
	SELECT
		AREA_CODE
		,ROUND((FOOD_EXP*1.00/CONSUMPTION_EXP*1.00)*100,1) RATIO
		,DENSE_RANK() OVER (ORDER BY ROUND((FOOD_EXP*1.00/CONSUMPTION_EXP*1.00)*100,1)) RANK
	FROM
		HOUSEHOLD_SURVEY
	WHERE
		SURVEY_YEAR = 2017
)
, C AS (
	SELECT
		AREA_CODE
		,ROUND((FOOD_EXP*1.00/CONSUMPTION_EXP*1.00)*100,1) RATIO
		,DENSE_RANK() OVER (ORDER BY ROUND((FOOD_EXP*1.00/CONSUMPTION_EXP*1.00)*100,1)) RANK
	FROM
		HOUSEHOLD_SURVEY
	WHERE
		SURVEY_YEAR = 2012
)
SELECT
	A.AREA_CODE AS CODE
	,D.AREA_NAME AS NAME
	,A.RANK AS '2022_RANK'
	,A.RATIO || '%'  AS '2022_RATIO'
	,B.RANK AS '2017_RANK'
	,B.RATIO || '%'  AS '2017_RATIO'
	,C.RANK AS '2012_RANK'
	,C.RATIO || '%' AS '2012_RATIO'
FROM A,B,C,AREA D
WHERE
	A.AREA_CODE = B.AREA_CODE
AND	A.AREA_CODE = C.AREA_CODE 
AND A.AREA_CODE = D.AREA_CODE
ORDER BY
	A.RANK,A.AREA_CODE DESC
提出情報
提出日時2024/01/11 14:50:33
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者yfuku
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
85 MB
データパターン3
AC
84 MB