ソースコード
select
"2020" as "SV_YEAR"
,p.pf_name as "PREFECTURE"
,eall.KIND as "KIND"
,eall.AMT as "AMT"
from 
(
select 
e.pf_code
, "小学校" as "KIND"
, 1 as no
,sum(e.elementary) as "AMT"
from ENROLLMENT_STATUS e
where e.survey_year=2020
and e.elementary is not null
group by e.pf_code
union all
select 
e.pf_code
, "中学校" as "KIND"
, 2 as no
,sum(e.middle) as "AMT"
from ENROLLMENT_STATUS e
where e.survey_year=2020
and e.middle is not null
group by e.pf_code
union all
select 
e.pf_code
, "高校" as "KIND"
, 3 as no
,sum(e.high) as "AMT"
from ENROLLMENT_STATUS e
where e.survey_year=2020
and e.high is not null
group by e.pf_code
union all
select 
e.pf_code
, "短大" as "KIND"
, 4 as no
,sum(e.junior_clg) as "AMT"
from ENROLLMENT_STATUS e
where e.survey_year=2020
and e.junior_clg is not null
group by e.pf_code
union all
select 
e.pf_code
, "大学" as "KIND"
, 5 as no
,sum(e.college) as "AMT"
from ENROLLMENT_STATUS e
where e.survey_year=2020
and e.college is not null
group by e.pf_code
union all
select 
e.pf_code
, "大学院" as "KIND"
, 6 as no
,sum(e.graduate) as "AMT"
from ENROLLMENT_STATUS e
where e.survey_year=2020
and e.graduate is not null
group by e.pf_code
) eall
,prefecture p
where eall.pf_code=p.pf_code
order by p.pf_code,eall.no
提出情報
提出日時2022/09/22 08:49:10
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者red3
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量95 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
95 MB
データパターン2
AC
95 MB