ソースコード
select  X.SURVEY_YEAR as SV_YEAR,PF.PF_NAME AS PREFECTURE,KIND,SUM(AMT) AS AMT
FROM (
 select SURVEY_YEAR ,PF_CODE , '小学校' AS KIND , ELEMENTARY AS AMT, 1 AS SORTORDER FROM ENROLLMENT_STATUS WHERE ELEMENTARY IS NOT NULL
 union all
 select SURVEY_YEAR ,PF_CODE , '中学校' AS KIND , MIDDLE AS AMT, 2 AS SORTORDER FROM ENROLLMENT_STATUS WHERE MIDDLE IS NOT NULL
 union all
 select SURVEY_YEAR ,PF_CODE , '高校' AS KIND , HIGH AS AMT, 3 AS SORTORDER FROM ENROLLMENT_STATUS WHERE HIGH IS NOT NULL
 union all
 select SURVEY_YEAR ,PF_CODE , '短大' AS KIND , JUNIOR_CLG AS AMT, 4 AS SORTORDER FROM ENROLLMENT_STATUS WHERE JUNIOR_CLG IS NOT NULL
 union all
 select SURVEY_YEAR ,PF_CODE , '大学' AS KIND , COLLEGE AS AMT, 5 AS SORTORDER FROM ENROLLMENT_STATUS WHERE COLLEGE IS NOT NULL
 union all
 select SURVEY_YEAR ,PF_CODE , '大学院' AS KIND , GRADUATE AS AMT, 6 AS SORTORDER FROM ENROLLMENT_STATUS WHERE GRADUATE IS NOT NULL
)X
LEFT OUTER JOIN PREFECTURE PF ON (PF.PF_CODE = X.PF_CODE)
WHERE X.SURVEY_YEAR = 2020
GROUP BY SV_YEAR,PF_NAME,KIND
ORDER BY X.PF_CODE,X.SORTORDER
提出情報
提出日時2022/09/21 23:29:15
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者piro
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量106 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
106 MB
データパターン2
AC
89 MB