ソースコード
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,
 ifnull(SUM(ELEMENTARY),0) 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,
 ifnull(SUM(MIDDLE),0) 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,
 ifnull(SUM(HIGH),0) 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,
 ifnull(SUM(JUNIOR_CLG),0) 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,
 ifnull(SUM(COLLEGE),0) 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,
 ifnull(SUM(GRADUATE),0) 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
 
order by a.PF_CODE,a.num
提出情報
提出日時2022/09/21 21:32:44
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者123qwe
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量100 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
90 MB
データパターン2
WA
100 MB