コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
select
SV_YEAR,
PREFECTURE,
KIND,
AMT
from
(select
survey_year as SV_YEAR,
e.pf_code,
pf_name as PREFECTURE,
"1" as kind_code,
"小学校" as KIND,
sum(elementary) as AMT
from enrollment_status as e
inner join prefecture as p
on e.pf_code = p.pf_code
where survey_year = 2020
and elementary is not null
group by e.pf_code
union
select
survey_year as SV_YEAR,
e.pf_code,
pf_name as PREFECTURE,
"2" as kind_code,
"中学校" as KIND,
sum(MIDDLE) as AMT
from enrollment_status as e
inner join prefecture as p
on e.pf_code = p.pf_code
where survey_year = 2020
and middle is not null
group by e.pf_code
union
select
survey_year as SV_YEAR,
e.pf_code,
pf_name as PREFECTURE,
"3" as kind_code,
"高校" as KIND,
sum(HIGH) as AMT
from enrollment_status as e
inner join prefecture as p
on e.pf_code = p.pf_code
where survey_year = 2020
and high is not null
group by e.pf_code
union
select
survey_year as SV_YEAR,
e.pf_code,
pf_name as PREFECTURE,
"4" as kind_code,
"短大" as KIND,
sum(JUNIOR_CLG) as AMT
from enrollment_status as e
inner join prefecture as p
on e.pf_code = p.pf_code
where survey_year = 2020
and JUNIOR_CLG is not null
group by e.pf_code
union
select
survey_year as SV_YEAR,
e.pf_code,
pf_name as PREFECTURE,
"5" as kind_code,
"大学" as KIND,
sum(COLLEGE) as AMT
from enrollment_status as e
inner join prefecture as p
on e.pf_code = p.pf_code
where survey_year = 2020
and COLLEGE is not null
group by e.pf_code
union
select
survey_year as SV_YEAR,
e.pf_code,
pf_name as PREFECTURE,
"6" as kind_code,
"大学院" as KIND,
sum(GRADUATE) as AMT
from enrollment_status as e
inner join prefecture as p
on e.pf_code = p.pf_code
where survey_year = 2020
and GRADUATE is not null
group by e.pf_code
)
order by pf_code,kind_code
提出情報
提出日時 | 2024/03/28 16:16:59 |
コンテスト | 第2回 SQLコンテスト |
問題 | 就学状況の表示変換 |
受験者 | sakichiii |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 86 MB |
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
86 MB