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