ソースコード
select
    area.area_code CODE,
    area_name NAME,
    dense_rank() over (order by T1.'2022_RATIO') as '2022_RANK',
    T1.'2022_RATIO' || '%' as '2022_RATIO',
    dense_rank() over (order by T2.'2017_RATIO') as '2017_RANK',
    T2.'2017_RATIO' || '%' as '2017_RATIO',
    dense_rank() over (order by T3.'2012_RATIO') as '2012_RANK',
    T3.'2012_RATIO' || '%' as '2012_RATIO'
from area
join
(
select
    area_code code,
    round(cast(food_exp as double) / consumption_exp * 100 , 1) as '2022_RATIO'
from household_survey
where
    survey_year = 2022
) as T1
on area.area_code = T1.code
join
(
select
    area_code code,
    round(cast(food_exp as double) / consumption_exp * 100 , 1) as '2017_RATIO'
from household_survey
where
    survey_year = 2017
) as T2
on area.area_code = T2.code
join
(
select
    area_code code,
    round(cast(food_exp as double) / consumption_exp * 100 , 1) as '2012_RATIO'
from household_survey
where
    survey_year = 2012
) as T3
on area.area_code = T3.code
order by
    T1.'2022_RATIO',
    CODE desc
提出情報
提出日時2023/12/17 13:01:36
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者platinum
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
83 MB
データパターン3
AC
86 MB