コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
with hs22 as(
select
aa.AREA_CODE as CODE,
aa.AREA_NAME as NAME,
dense_rank() over (ORDER BY round((cast(hs.FOOD_EXP as real)/cast(hs.CONSUMPTION_EXP as real)) * 100,1) ASC) as rank,
round((cast(hs.FOOD_EXP as real)/cast(hs.CONSUMPTION_EXP as real)) * 100,1) || '%' as ratio
from HOUSEHOLD_SURVEY as hs
inner join AREA as aa on hs.AREA_CODE = aa.AREA_CODE
where SURVEY_YEAR = 2022
),hs17 as (
select
aa.AREA_CODE as CODE,
aa.AREA_NAME as NAME,
dense_rank() over (ORDER BY round((cast(hs.FOOD_EXP as real)/cast(hs.CONSUMPTION_EXP as real)) * 100,1) ASC) as rank,
round((cast(hs.FOOD_EXP as real)/cast(hs.CONSUMPTION_EXP as real)) * 100,1) || '%' as ratio
from HOUSEHOLD_SURVEY as hs
inner join AREA as aa on hs.AREA_CODE = aa.AREA_CODE
where SURVEY_YEAR = 2017
),hs12 as (
select
aa.AREA_CODE as CODE,
aa.AREA_NAME as NAME,
dense_rank() over (ORDER BY round((cast(hs.FOOD_EXP as real)/cast(hs.CONSUMPTION_EXP as real)) * 100,1) ASC) as rank,
round((cast(hs.FOOD_EXP as real)/cast(hs.CONSUMPTION_EXP as real)) * 100,1) || '%' as ratio
from HOUSEHOLD_SURVEY as hs
inner join AREA as aa on hs.AREA_CODE = aa.AREA_CODE
where SURVEY_YEAR = 2012
)
select
aa.AREA_CODE as CODE,
aa.AREA_NAME as NAME,
hs22.rank as '2022_RANK',
hs22.ratio as '2022_RATIO',
hs17.rank as '2017_RANK',
hs17.ratio as '2017_RATIO',
hs12.rank as '2012_RANK',
hs12.ratio as '2012_RATIO'
from AREA as aa
inner join hs22 on aa.AREA_CODE = hs22.CODE
inner join hs17 on aa.AREA_CODE = hs17.CODE
inner join hs12 on aa.AREA_CODE = hs12.CODE
order by
hs22.rank asc,
CODE desc;
提出情報
提出日時 | 2024/07/19 10:40:27 |
コンテスト | 第10回 SQLコンテスト |
問題 | 食料費の割合 |
受験者 | asano |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 84 MB |
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
84 MB
データパターン3
AC
84 MB