ソースコード
SELECT
SURVEY_YEAR SV_YEAR,
PF_NAME PREFECTURE,
KIND,
SUM(W_AMT) AS AMT
FROM (
SELECT SURVEY_YEAR,PF_CODE,AGE,ELEMENTARY AS W_AMT, '小学校' AS KIND, 0 AS KI FROM ENROLLMENT_STATUS WHERE ELEMENTARY > 0
UNION ALL
SELECT SURVEY_YEAR,PF_CODE,AGE,MIDDLE AS W_AMT,      '中学校' AS KIND, 1 AS KI FROM ENROLLMENT_STATUS WHERE MIDDLE > 0
UNION ALL
SELECT SURVEY_YEAR,PF_CODE,AGE,HIGH AS W_AMT,       '高校' AS KIND, 2 AS KI FROM ENROLLMENT_STATUS WHERE HIGH > 0
UNION ALL
SELECT SURVEY_YEAR,PF_CODE,AGE,JUNIOR_CLG AS W_AMT,'短大' AS KIND, 3 AS KI FROM ENROLLMENT_STATUS WHERE JUNIOR_CLG > 0
UNION ALL
SELECT SURVEY_YEAR,PF_CODE,AGE,COLLEGE AS W_AMT,    '大学' AS KIND, 4  AS KI FROM ENROLLMENT_STATUS WHERE COLLEGE > 0
UNION ALL
SELECT SURVEY_YEAR,PF_CODE,AGE,GRADUATE AS W_AMT,    '大学院' AS KIND, 5 AS KI FROM ENROLLMENT_STATUS WHERE GRADUATE > 0
) S JOIN PREFECTURE USING(PF_CODE)
WHERE 				
SURVEY_YEAR = 2020
GROUP BY SURVEY_YEAR,PF_CODE,KIND,KI
HAVING AMT IS NOT NULL
ORDER BY PF_CODE ASC, KI ASC
提出情報
提出日時2022/09/21 20:30:41
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者na
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量97 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
95 MB
データパターン2
AC
97 MB