ソースコード
SELECT
      a2.SURVEY_YEAR "SV_YEAR"
    , b.PF_NAME "PREFECTURE"
    , a2.KIND
    , SUM( 
        CASE 
            WHEN a2.KIND = '小学校' 
                THEN a2.ELEMENTARY 
            WHEN a2.KIND = '中学校' 
                THEN a2.ELEMENTARY 
            WHEN a2.KIND = '高校' 
                THEN a2.ELEMENTARY 
            WHEN a2.KIND = '短大' 
                THEN a2.ELEMENTARY 
            WHEN a2.KIND = '大学' 
                THEN a2.ELEMENTARY 
            WHEN a2.KIND = '大学院' 
                THEN a2.ELEMENTARY 
            ELSE 0 
            END
    ) "AMT" 
FROM
    ( 
        SELECT
              a.SURVEY_YEAR
            , a.PF_CODE
            , a.ELEMENTARY
            , "小学校" "KIND" 
        FROM
            ENROLLMENT_STATUS a 
        WHERE
            a.SURVEY_YEAR = 2020 
        UNION ALL 
        SELECT
              a.SURVEY_YEAR
            , a.PF_CODE
            , a.MIDDLE
            , "中学校" "KIND" 
        FROM
            ENROLLMENT_STATUS a 
        WHERE
            a.SURVEY_YEAR = 2020 
        UNION ALL 
        SELECT
              a.SURVEY_YEAR
            , a.PF_CODE
            , a.HIGH
            , "高校" "KIND" 
        FROM
            ENROLLMENT_STATUS a 
        WHERE
            a.SURVEY_YEAR = 2020 
        UNION ALL 
        SELECT
              a.SURVEY_YEAR
            , a.PF_CODE
            , a.JUNIOR_CLG
            , "短大" "KIND" 
        FROM
            ENROLLMENT_STATUS a 
        WHERE
            a.SURVEY_YEAR = 2020 
        UNION ALL 
        SELECT
              a.SURVEY_YEAR
            , a.PF_CODE
            , a.COLLEGE
            , "大学" "KIND" 
        FROM
            ENROLLMENT_STATUS a 
        WHERE
            a.SURVEY_YEAR = 2020 
        UNION ALL 
        SELECT
              a.SURVEY_YEAR
            , a.PF_CODE
            , a.GRADUATE
            , "大学院" "KIND" 
        FROM
            ENROLLMENT_STATUS a 
        WHERE
            a.SURVEY_YEAR = 2020
    ) a2 
    INNER JOIN PREFECTURE b 
        ON a2.PF_CODE = b.PF_CODE 
WHERE
    a2.ELEMENTARY IS NOT NULL 
GROUP BY
    b.PF_NAME
    , a2.KIND 
ORDER BY
    a2.PF_CODE
    , CASE 
        WHEN a2.KIND = '小学校' 
            THEN 1 
        WHEN a2.KIND = '中学校' 
            THEN 2 
        WHEN a2.KIND = '高校' 
            THEN 3 
        WHEN a2.KIND = '短大' 
            THEN 4 
        WHEN a2.KIND = '大学' 
            THEN 5 
        WHEN a2.KIND = '大学院' 
            THEN 6 
        ELSE 0 
        END
提出情報
提出日時2024/05/06 02:12:56
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者fattywhale
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
84 MB