ソースコード
WITH H22 AS (SELECT AREA_CODE, ROUND(FOOD_EXP * 100.0 / CONSUMPTION_EXP, 1) AS R FROM HOUSEHOLD_SURVEY WHERE SURVEY_YEAR = 2022),
  H17 AS (SELECT AREA_CODE, ROUND(FOOD_EXP * 100.0 / CONSUMPTION_EXP, 1) AS R FROM HOUSEHOLD_SURVEY WHERE SURVEY_YEAR = 2017),
  H12 AS (SELECT AREA_CODE, ROUND(FOOD_EXP * 100.0 / CONSUMPTION_EXP, 1) AS R FROM HOUSEHOLD_SURVEY WHERE SURVEY_YEAR = 2012)
SELECT A.AREA_CODE AS CODE, AREA_NAME AS NAME,
  DENSE_RANK() OVER (ORDER BY H22.R) AS '2022_RANK', H22.R || '%' AS '2022_RATIO',
  DENSE_RANK() OVER (ORDER BY H17.R) AS '2017_RANK', H17.R || '%' AS '2017_RATIO',
  DENSE_RANK() OVER (ORDER BY H12.R) AS '2012_RANK', H12.R || '%' AS '2012_RATIO'
FROM AREA A
JOIN H22 USING (AREA_CODE)
JOIN H17 USING (AREA_CODE)
JOIN H12 USING (AREA_CODE)
ORDER BY 3, 1 DESC;
提出情報
提出日時2023/12/16 13:08:09
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者matsuu
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
85 MB
データパターン3
AC
85 MB