ソースコード
with s2022 as(
select
	 AREA_CODE
	,round(FOOD_EXP * 1.0 / CONSUMPTION_EXP * 100.0 , 1) || '%' as RATIO
from HOUSEHOLD_SURVEY
where SURVEY_YEAR = 2022
)
, s2017 as(
select
	 AREA_CODE
	,round(FOOD_EXP * 1.0 / CONSUMPTION_EXP * 100.0 , 1) || '%' as RATIO
from HOUSEHOLD_SURVEY
where SURVEY_YEAR = 2017
)
, s2012 as(
select
	 AREA_CODE
	,round(FOOD_EXP * 1.0 / CONSUMPTION_EXP * 100.0 , 1) || '%' as RATIO
from HOUSEHOLD_SURVEY
where SURVEY_YEAR = 2012
)
select
	 s2022.AREA_CODE as CODE
	,AREA.AREA_NAME  as NAME
	,dense_rank() over (order by s2022.RATIO) as "2022_RANK"
	,s2022.RATIO as "2022_RATIO"
	,dense_rank() over (order by s2017.RATIO) as "2017_RANK"
	,s2017.RATIO as "2017_RATIO"
	,dense_rank() over (order by s2012.RATIO) as "2012_RANK"
	,s2012.RATIO as "2012_RATIO"
from s2022
	 inner join s2017
	 on  s2022.AREA_CODE = s2017.AREA_CODE
	 inner join s2012
	 on  s2017.AREA_CODE = s2012.AREA_CODE
	 inner join AREA
	 on  s2022.AREA_CODE = AREA.AREA_CODE
order by
	 "2022_RANK"
	,CODE desc
提出情報
提出日時2023/12/18 16:33:37
コンテスト第10回 SQLコンテスト
問題食料費の割合
受験者ckoga
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量92 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
92 MB
データパターン2
AC
88 MB
データパターン3
AC
88 MB