ソースコード
select
  CODE,
  NAME,
  DENSE_RANK() over(order by "2022_RATIO") as "2022_RANK",
  "2022_RATIO" || '%' as "2022_RATIO",
  DENSE_RANK() over(order by "2017_RATIO") as "2017_RANK",
  "2017_RATIO" || '%' as "2017_RATIO",
  DENSE_RANK() over(order by "2012_RATIO") as "2012_RANK",
  "2012_RATIO" || '%' as "2012_RATIO"
from (
select
  AREA.AREA_CODE as CODE,
  AREA.AREA_NAME as NAME,
  round(cast(HS2022.FOOD_EXP as real)/HS2022.CONSUMPTION_EXP*100, 1) as "2022_RATIO",
  round(cast(HS2017.FOOD_EXP as real)/HS2017.CONSUMPTION_EXP*100, 1) as "2017_RATIO",
  round(cast(HS2012.FOOD_EXP as real)/HS2012.CONSUMPTION_EXP*100, 1) as "2012_RATIO"
  from AREA
  inner join HOUSEHOLD_SURVEY as HS2022 on AREA.AREA_CODE = HS2022.AREA_CODE and HS2022.SURVEY_YEAR = 2022
  inner join HOUSEHOLD_SURVEY as HS2017 on AREA.AREA_CODE = HS2017.AREA_CODE and HS2017.SURVEY_YEAR = 2017
  inner join HOUSEHOLD_SURVEY as HS2012 on AREA.AREA_CODE = HS2012.AREA_CODE and HS2012.SURVEY_YEAR = 2012
) t
order by
"2022_RANK" asc,
CODE desc

提出情報
提出日時2023/12/18 00:58:17
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者ngyuki
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
86 MB
データパターン3
AC
85 MB