ソースコード
SELECT
 TM.YEAR as SV_YEAR,PR.PF_NAME as PREFECTURE,TM.KIND,TM.AMT
FROM
    (
        SELECT PF_CODE,'小学校' as KIND,SUM(ELEMENTARY) as AMT,SURVEY_YEAR YEAR
        FROM ENROLLMENT_STATUS
        GROUP BY PF_CODE
        HAVING AMT IS NOT NULL
        UNION
        SELECT PF_CODE,'中学校' as KIND, SUM(MIDDLE) as AMT, SURVEY_YEAR YEAR
        FROM ENROLLMENT_STATUS
        GROUP BY PF_CODE
        HAVING AMT IS NOT NULL
        UNION
        SELECT PF_CODE,'高校' as KIND,SUM(HIGH) as AMT,SURVEY_YEAR YEAR
        FROM ENROLLMENT_STATUS
        GROUP BY PF_CODE
        HAVING AMT IS NOT NULL
        UNION
        SELECT PF_CODE,'短大' as KIND,SUM(JUNIOR_CLG) as AMT,SURVEY_YEAR YEAR
        FROM ENROLLMENT_STATUS
        GROUP BY PF_CODE
        HAVING AMT IS NOT NULL
        UNION
        SELECT PF_CODE,'大学' as KIND,SUM(COLLEGE) as AMT,SURVEY_YEAR YEAR
        FROM ENROLLMENT_STATUS
        GROUP BY PF_CODE
        HAVING AMT IS NOT NULL
        UNION
        SELECT PF_CODE,'大学院' as KIND,SUM(GRADUATE) as AMT,SURVEY_YEAR as YEAR
        FROM ENROLLMENT_STATUS
        GROUP BY PF_CODE
        HAVING AMT IS NOT NULL
    ) TM,
    PREFECTURE PR
WHERE TM.PF_CODE = PR.PF_CODE AND TM.YEAR = '2020'
ORDER BY TM.PF_CODE ASC,TM.KIND = '小学校' DESC,TM.KIND = '中学校' DESC,TM.KIND = '高校' DESC,TM.KIND = '短大' DESC,TM.KIND = '大学' DESC,TM.KIND = '大学院' DESC
提出情報
提出日時2022/09/22 23:40:20
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者YusukeYonetani
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
78 MB
データパターン2
WA
76 MB