ソースコード
SELECT 
    '2020' SV_YEAR
    , PF_NAME PREFECTURE
    , KIND
    , AMT
FROM (SELECT 
        PF_CODE 
        ,'小学校' KIND
        ,SUM(ELEMENTARY) AMT
        ,1 J
    FROM ENROLLMENT_STATUS
    WHERE SURVEY_YEAR = '2020'
    GROUP BY PF_CODE
    UNION ALL
    SELECT 
        PF_CODE 
        ,'中学校' KIND
        ,SUM(MIDDLE) AMT
        ,2 J
    FROM ENROLLMENT_STATUS
    WHERE SURVEY_YEAR = '2020'
    GROUP BY PF_CODE
    UNION ALL
    SELECT 
        PF_CODE 
        ,'高校' KIND
        ,SUM(HIGH) AMT
        ,3 J
    FROM ENROLLMENT_STATUS
    WHERE SURVEY_YEAR = '2020'
    GROUP BY PF_CODE
    UNION ALL
    SELECT 
        PF_CODE 
        ,'短大' KIND
        ,SUM(JUNIOR_CLG) AMT
        ,4 J
    FROM ENROLLMENT_STATUS
    WHERE SURVEY_YEAR = '2020'
    GROUP BY PF_CODE
    UNION ALL
    SELECT 
        PF_CODE 
        ,'大学' KIND
        ,SUM(COLLEGE) AMT
        ,5 J
    FROM ENROLLMENT_STATUS
    WHERE SURVEY_YEAR = '2020'
    GROUP BY PF_CODE
    UNION ALL
    SELECT 
        PF_CODE 
        ,'大学院' KIND
        ,SUM(GRADUATE) AMT
        ,6 J
    FROM ENROLLMENT_STATUS
    WHERE SURVEY_YEAR = '2020'
    GROUP BY PF_CODE ) A
INNER JOIN PREFECTURE
ON PREFECTURE.PF_CODE = A.PF_CODE
WHERE AMT IS NOT NULL
ORDER BY A.PF_CODE
,J


提出情報
提出日時2022/10/03 17:56:37
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者lux
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
79 MB
データパターン2
AC
79 MB