ソースコード
SELECT T1.AREA_CODE CODE
      ,T1.AREA_NAME NAME
      ,T2."2022_RANK" "2022_RANK"
      ,T2."2022_RATIO" "2022_RATIO"
      ,T3."2017_RANK" "2017_RANK"
      ,T3."2017_RATIO" "2017_RATIO"
      ,T4."2012_RANK" "2012_RANK"
      ,T4."2012_RATIO" "2012_RATIO"
FROM AREA T1
INNER JOIN 
(
SELECT AREA_CODE CODE
      ,DENSE_RANK() OVER(ORDER BY ROUND((100.0*FOOD_EXP) / (100.0*CONSUMPTION_EXP) * 100,1) ASC) "2022_RANK"
      ,ROUND((100.0*FOOD_EXP) / (100.0*CONSUMPTION_EXP) * 100,1) || '%' "2022_RATIO"
  FROM HOUSEHOLD_SURVEY
 WHERE SURVEY_YEAR = '2022'
 GROUP BY AREA_CODE
) T2
ON T1.AREA_CODE = T2.CODE
INNER JOIN 
(
SELECT AREA_CODE CODE
      ,DENSE_RANK() OVER(ORDER BY ROUND((100.0*FOOD_EXP) / (100.0*CONSUMPTION_EXP) * 100,1) ASC) "2017_RANK"
      ,ROUND((100.0*FOOD_EXP) / (100.0*CONSUMPTION_EXP) * 100,1) || '%' "2017_RATIO"
  FROM HOUSEHOLD_SURVEY
 WHERE SURVEY_YEAR = '2017'
 GROUP BY AREA_CODE
) T3
ON T1.AREA_CODE = T3.CODE
INNER JOIN 
(
SELECT AREA_CODE CODE
      ,DENSE_RANK() OVER(ORDER BY ROUND((100.0*FOOD_EXP) / (100.0*CONSUMPTION_EXP) * 100,1) ASC) "2012_RANK"
      ,ROUND((100.0*FOOD_EXP) / (100.0*CONSUMPTION_EXP) * 100,1) || '%' "2012_RATIO"
  FROM HOUSEHOLD_SURVEY
 WHERE SURVEY_YEAR = '2012'
 GROUP BY AREA_CODE
) T4
ON T1.AREA_CODE = T4.CODE
ORDER BY T2."2022_RATIO",CODE DESC
提出情報
提出日時2023/12/18 11:49:20
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者Tsukamon
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量102 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
98 MB
データパターン2
AC
85 MB
データパターン3
AC
102 MB