ソースコード
SELECT
    T.SURVEY_YEAR SV_YEAR,
    P.PF_NAME PREFECTURE,
    T.KIND,
    T.AMT
    
FROM
    (
    SELECT 1 SORT, "小学校" KIND, SUM(ELEMENTARY) AMT, PF_CODE,SURVEY_YEAR FROM
        ENROLLMENT_STATUS
        GROUP BY PF_CODE,SURVEY_YEAR
    UNION
        SELECT 2 SORT,"中学校" KIND, SUM(MIDDLE) AMT, PF_CODE,SURVEY_YEAR FROM
            ENROLLMENT_STATUS
        GROUP BY PF_CODE,SURVEY_YEAR
    UNION 
        SELECT 3 SORT, "高校" KIND, SUM(HIGH) AMT, PF_CODE,SURVEY_YEAR FROM
            ENROLLMENT_STATUS
        GROUP BY PF_CODE,SURVEY_YEAR
    UNION
        SELECT 4 SORT, "短大" KIND, SUM(JUNIOR_CLG) AMT, PF_CODE,SURVEY_YEAR FROM
            ENROLLMENT_STATUS
        GROUP BY PF_CODE,SURVEY_YEAR
    UNION
        SELECT 5 SORT, "大学" KIND, SUM(COLLEGE) AMT, PF_CODE,SURVEY_YEAR FROM
            ENROLLMENT_STATUS
        WHERE COLLEGE IS NOT NULL
        GROUP BY PF_CODE,SURVEY_YEAR
    UNION
        SELECT 6 SORT, "大学院" KIND, SUM(GRADUATE) AMT, PF_CODE,SURVEY_YEAR FROM
            ENROLLMENT_STATUS
        GROUP BY PF_CODE,SURVEY_YEAR
    ) T
    INNER JOIN PREFECTURE P ON T.PF_CODE = P.PF_CODE
WHERE T.SURVEY_YEAR = 2020 AND AMT IS NOT NULL
ORDER BY P.PF_CODE ASC,T.SORT ASC
提出情報
提出日時2023/09/16 10:08:46
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者fractal1024
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
78 MB
データパターン2
AC
77 MB