ソースコード
with base as (
select
    t2022.AREA_CODE
    ,round(100.0*t2022.FOOD_EXP/t2022.CONSUMPTION_EXP,1) as `2022_RATIO`
    ,round(100.0*t2017.FOOD_EXP/t2017.CONSUMPTION_EXP,1) as `2017_RATIO`
    ,round(100.0*t2012.FOOD_EXP/t2012.CONSUMPTION_EXP,1) as `2012_RATIO`
from
    HOUSEHOLD_SURVEY as t2022
    inner join
    HOUSEHOLD_SURVEY as t2017
    on t2022.AREA_CODE = t2017.AREA_CODE
    and t2022.SURVEY_YEAR=2022
    and t2017.SURVEY_YEAR=2017
    inner join
    HOUSEHOLD_SURVEY as t2012
    on t2022.AREA_CODE = t2012.AREA_CODE
    and t2022.SURVEY_YEAR=2022
    and t2012.SURVEY_YEAR=2012
)
select
    b.AREA_CODE as CODE
    ,a.AREA_NAME as 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
    base as b
    inner join
    AREA as a
    on b.AREA_CODE = a.AREA_CODE
order by
    `2022_RANK`
    ,b.AREA_CODE desc
提出情報
提出日時2024/03/14 13:50:48
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者gP2fWnUzTL
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
84 MB
データパターン3
AC
84 MB