ソースコード
with
  s2022 as (select AREA_CODE, round(FOOD_EXP * 100.0 / CONSUMPTION_EXP, 1) as RATIO from HOUSEHOLD_SURVEY where SURVEY_YEAR = 2022)
, s2017 as (select AREA_CODE, round(FOOD_EXP * 100.0 / CONSUMPTION_EXP, 1) as RATIO from HOUSEHOLD_SURVEY where SURVEY_YEAR = 2017)
, s2012 as (select AREA_CODE, round(FOOD_EXP * 100.0 / CONSUMPTION_EXP, 1) as RATIO from HOUSEHOLD_SURVEY where SURVEY_YEAR = 2012)
select
    s2022.AREA_CODE  as CODE
  , AREA_NAME        as NAME
  , s2022.RATIO || '%'                    as "2022_RATIO"
  , DENSE_RANK() over(order by s2022.RATIO asc) as "2022_RANK"
  , s2017.RATIO || '%'                    as "2017_RATIO"
  , DENSE_RANK() over(order by s2017.RATIO asc) as "2017_RANK"
  , s2012.RATIO || '%'                    as "2012_RATIO"
  , DENSE_RANK() over(order by s2012.RATIO asc) as "2012_RANK"
from
  s2022
  inner join s2017 using(AREA_CODE)
  inner join s2012 using(AREA_CODE)
  inner join AREA  using(AREA_CODE)
order by 
    "2022_RANK" asc
  , AREA_CODE desc
;

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