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