ソースコード
with survey_2022 as (
    select area_code, round(100.0 * food_exp / consumption_exp, 1) || '%' as `2022_RATIO`
    from household_survey
    where survey_year = 2022
    order by `2022_RATIO`
),
survey_2017 as (
    select area_code, round(100.0 * food_exp / consumption_exp, 1) || '%' as `2017_RATIO`
    from household_survey
    where survey_year = 2017
    order by `2017_RATIO`
),
survey_2012 as (
    select area_code, round(100.0 * food_exp / consumption_exp, 1) || '%' as `2012_RATIO`
    from household_survey
    where survey_year = 2012
    order by `2012_RATIO`
)
select
    area.area_code as CODE,
    area.area_name as NAME,
    dense_rank() over (order by `2022_RATIO`) as `2022_RANK`,
    `2022_RATIO`,
    dense_rank() over (order by `2017_RATIO`) as `2017_RANK`,
    `2017_RATIO`,
    dense_rank() over (order by `2012_RATIO`) as `2012_RANK`,
    `2012_RATIO`
from area
left join survey_2022
    on  area.area_code = survey_2022.area_code
left join survey_2017
    on area.area_code = survey_2017.area_code
left join survey_2012
    on area.area_code = survey_2012.area_code
order by
    `2022_RATIO` asc,
    CODE desc
提出情報
提出日時2023/12/17 17:01:40
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者toshikish
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
88 MB
データパターン2
AC
82 MB
データパターン3
AC
87 MB