ソースコード
select
 SURVEY_YEAR as SV_YEAR
,PREFECTURE.PF_NAME as PREFECTURE
,KIND
,amount as AMT
from(

select
 SURVEY_YEAR
,PF_CODE
,'小学校' as KIND
,sum(ELEMENTARY) as amount
,1 as disp
from ENROLLMENT_STATUS
where
 SURVEY_YEAR = 2020
group by 
 SURVEY_YEAR
,PF_CODE

union all

select
 SURVEY_YEAR
,PF_CODE
,'中学校' as KIND
,sum(MIDDLE) as amount
,2 as disp
from ENROLLMENT_STATUS
where
 SURVEY_YEAR = 2020
group by 
 SURVEY_YEAR
,PF_CODE

union all

select
 SURVEY_YEAR
,PF_CODE
,'高校' as KIND
,sum(HIGH) as amount
,3 as disp
from ENROLLMENT_STATUS
where
 SURVEY_YEAR = 2020
group by 
 SURVEY_YEAR
,PF_CODE

union all

select
 SURVEY_YEAR
,PF_CODE
,'短大' as KIND
,sum(JUNIOR_CLG) as amount
,4 as disp
from ENROLLMENT_STATUS
where
 SURVEY_YEAR = 2020
group by 
 SURVEY_YEAR
,PF_CODE

union all

select
 SURVEY_YEAR
,PF_CODE
,'大学' as KIND
,sum(COLLEGE) as amount
,5 as disp
from ENROLLMENT_STATUS
where
 SURVEY_YEAR = 2020
group by 
 SURVEY_YEAR
,PF_CODE

union all

select
 SURVEY_YEAR
,PF_CODE
,'大学院' as KIND
,sum(GRADUATE) as amount
,6 as disp
from ENROLLMENT_STATUS
where
 SURVEY_YEAR = 2020
group by 
 SURVEY_YEAR
,PF_CODE

)as main
inner join
 PREFECTURE
 on main.PF_CODE = PREFECTURE.PF_CODE
where amount is not null
order by
 main.PF_CODE
,main.disp
提出情報
提出日時2022/09/22 00:47:22
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者visionary_band
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量98 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
98 MB