ソースコード
WITH T22 as (
SELECT
  AREA_CODE, ROUND(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1) hiri
FROM HOUSEHOLD_SURVEY
WHERE SURVEY_YEAR = 2022
), T17 as (
SELECT
  AREA_CODE, ROUND(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1) hiri
FROM HOUSEHOLD_SURVEY
WHERE SURVEY_YEAR = 2017
), T12 as (
SELECT
  AREA_CODE, ROUND(100.0 * FOOD_EXP / CONSUMPTION_EXP, 1) hiri
FROM HOUSEHOLD_SURVEY
WHERE SURVEY_YEAR = 2012
)

SELECT
  T22.AREA_CODE as CODE
 ,A.AREA_NAME as NAME
 ,dense_rank() OVER (ORDER BY T22.hiri) as `2022_RANK`
 ,T22.hiri || '%' as `2022_RATIO`
 ,dense_rank() OVER (ORDER BY T17.hiri) as `2017_RANK`
 ,T17.hiri || '%' as `2017_RATIO`
 ,dense_rank() OVER (ORDER BY T12.hiri) as `2012_RANK`
 ,T12.hiri || '%' as `2012_RATIO`
FROM T22
JOIN AREA A ON T22.AREA_CODE = A.AREA_CODE
JOIN T17 ON T22.AREA_CODE = T17.AREA_CODE
JOIN T12 ON T22.AREA_CODE = T12.AREA_CODE
ORDER BY 3, 1 DESc
提出情報
提出日時2023/12/17 19:24:16
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者mine
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
85 MB
データパターン3
AC
85 MB