ソースコード
with rank_2022 as(
select
    area_code 
    ,round(100.0*food_exp/consumption_exp,1) as ratio
    ,dense_rank()over(order by round(100.0*food_exp/consumption_exp,1) ) as r
from household_survey
where survey_year = '2022'
)
,rank_2017 as(
select
    area_code 
    ,round(100.0*food_exp/consumption_exp,1) as ratio
    ,dense_rank()over(order by round(100.0*food_exp/consumption_exp,1) ) as r
from household_survey
where survey_year = '2017'
)
,rank_2012 as(
select
    area_code 
    ,round(100.0*food_exp/consumption_exp,1) as ratio
    ,dense_rank()over(order by round(100.0*food_exp/consumption_exp,1) ) as r
from household_survey
where survey_year = '2012'
)
select 
rank_2022.area_code as CODE
,area_name as NAME
,rank_2022.r as '2022_RANK'
,rank_2022.ratio||'%' as '2022_RATIO'
,rank_2017.r as '2017_RANK'
,rank_2017.ratio||'%' as '2017_RATIO'
,rank_2012.r as '2012_RANK'
,rank_2012.ratio||'%' as '2012_RATIO'
from rank_2022
inner join rank_2017
on rank_2022.area_code = rank_2017.area_code
inner join rank_2012
on rank_2022.area_code = rank_2012.area_code
inner join area
on area.area_code = rank_2022.area_code
order by rank_2022.r,CODE desc
提出情報
提出日時2024/06/20 10:55:54
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者HamamatsuUnagi
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
85 MB
データパターン3
AC
84 MB