ソースコード
SELECT SURVEY_YEAR AS SV_YEAR,PF_NAME AS PREFECTURE,KIND,AMT
FROM
(
	SELECT SURVEY_YEAR,PF_CODE,KIND,SUM(AMT) AMT,SORT
	FROM (
		SELECT SURVEY_YEAR,PF_CODE,ELEMENTARY AS AMT,'小学校' AS KIND ,0 AS SORT
		FROM
			ENROLLMENT_STATUS
		WHERE ELEMENTARY IS NOT NULL
		UNION
		SELECT SURVEY_YEAR,PF_CODE,MIDDLE AS AMT,'中学校' AS KIND ,1 AS SORT
		FROM
			ENROLLMENT_STATUS
		WHERE MIDDLE IS NOT NULL
		UNION
		SELECT SURVEY_YEAR,PF_CODE,HIGH AS AMT,'高校' AS KIND ,2 AS SORT
		FROM
			ENROLLMENT_STATUS
		WHERE HIGH IS NOT NULL
		UNION
		SELECT SURVEY_YEAR,PF_CODE,JUNIOR_CLG AS AMT,'短大' AS KIND ,3 AS SORT
		FROM
			ENROLLMENT_STATUS
		WHERE JUNIOR_CLG IS NOT NULL
		UNION
		SELECT SURVEY_YEAR,PF_CODE,COLLEGE AS AMT,'大学' AS KIND ,4 AS SORT
		FROM
			ENROLLMENT_STATUS
		WHERE COLLEGE IS NOT NULL
		UNION
		SELECT SURVEY_YEAR,PF_CODE,GRADUATE AS AMT,'大学院' AS KIND ,5 AS SORT
		FROM
			ENROLLMENT_STATUS
		WHERE GRADUATE IS NOT NULL
	)
	WHERE SURVEY_YEAR = '2020'
	GROUP BY SURVEY_YEAR,PF_CODE,KIND
) A
	,PREFECTURE B
WHERE A.PF_CODE = B.PF_CODE
ORDER BY A.PF_CODE,A.SORT
提出情報
提出日時2022/09/22 12:03:16
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者yfuku
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量97 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
96 MB
データパターン2
WA
97 MB