ソースコード
with t22 as (
select area_code as a,
round(FOOD_EXP*100.0/CONSUMPTION_EXP,1) as r,
dense_rank() 
over(order by 
round(FOOD_EXP*100.0/CONSUMPTION_EXP,1)
) as o
from HOUSEHOLD_SURVEY as h
where SURVEY_YEAR=2022
group by area_code
), t17 as (
select area_code as a,
round(FOOD_EXP*100.0/CONSUMPTION_EXP,1) as r,
dense_rank() 
over(order by 
round(FOOD_EXP*100.0/CONSUMPTION_EXP,1)
) as o
from HOUSEHOLD_SURVEY as h
where SURVEY_YEAR=2017
group by area_code
), t12 as (
select area_code as a,
round(FOOD_EXP*100.0/CONSUMPTION_EXP,1) as r,
dense_rank() 
over(order by 
round(FOOD_EXP*100.0/CONSUMPTION_EXP,1)
) as o
from HOUSEHOLD_SURVEY as h
where SURVEY_YEAR=2012
group by area_code
)
select AREA_CODE as 'CODE',
area_name as 'NAME',
t22.o as '2022_RANK',
t22.r||'%' as '2022_RATIO',
t17.o as '2017_RANK',
t17.r||'%' as '2017_RATIO',
t12.o as '2012_RANK',
t12.r||'%' as '2012_RATIO'
from area as a
inner join t22 on t22.a=a.area_code
inner join t17 on t17.a=a.area_code
inner join t12 on t12.a=a.area_code
order by 3 asc, 1 desc
提出情報
提出日時2023/12/18 01:49:48
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者tabr
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
85 MB
データパターン3
AC
85 MB