ソースコード
select
a.SURVEY_YEAR as SV_YEAR,
b.PF_NAME as PREFECTURE,
a.KIND,
a.AMT
from 
(
select
 SURVEY_YEAR,
 PF_CODE,
 '1' as num,
 '小学校' as KIND,
 SUM(ELEMENTARY) as AMT
from ENROLLMENT_STATUS
where SURVEY_YEAR = '2020'
group by PF_CODE
union all
select
 SURVEY_YEAR,
 PF_CODE,
 '2' as num,
 '中学校' as KIND,
 SUM(MIDDLE) as AMT
from ENROLLMENT_STATUS
where SURVEY_YEAR = '2020'
group by PF_CODE
union all
select
 SURVEY_YEAR,
 PF_CODE,
 '3' as num,
 '高校' as KIND,
 SUM(HIGH) as AMT
from ENROLLMENT_STATUS
where SURVEY_YEAR = '2020'
group by PF_CODE
union all
select
 SURVEY_YEAR,
 PF_CODE,
 '4' as num,
 '短大' as KIND,
 SUM(JUNIOR_CLG) as AMT
from ENROLLMENT_STATUS
where SURVEY_YEAR = '2020'
group by PF_CODE
union all
select
 SURVEY_YEAR,
 PF_CODE,
 '5' as num,
 '大学' as KIND,
 SUM(COLLEGE) as AMT
from ENROLLMENT_STATUS
where SURVEY_YEAR = '2020'
group by PF_CODE
union all
select
 SURVEY_YEAR,
 PF_CODE,
 '6' as num,
 '大学院' as KIND,
 SUM(GRADUATE) as AMT
from ENROLLMENT_STATUS
where SURVEY_YEAR = '2020'
group by PF_CODE
) a
left outer join PREFECTURE b
 on a.PF_CODE = b.PF_CODE
where a.AMT is not null
order by a.PF_CODE,a.num
提出情報
提出日時2022/09/21 21:35:26
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者123qwe
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量100 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
93 MB
データパターン2
AC
100 MB