ソースコード
SELECT 
    SURVEY_YEAR
    ,PF_NAME
    ,KIND
    ,SUM(AMT) AS AMT
FROM 
(
SELECT 
    SURVEY_YEAR
    ,PF_CODE
    ,AGE
    ,ELEMENTARY AS AMT
    ,"小学校" AS KIND 
    ,"1" AS KINDID
FROM ENROLLMENT_STATUS
UNION ALL
SELECT 
    SURVEY_YEAR
    ,PF_CODE
    ,AGE
    ,MIDDLE AS AMT
    ,"中学校" AS KIND 
    ,"2" AS KINDID
FROM ENROLLMENT_STATUS
UNION ALL
SELECT 
    SURVEY_YEAR
    ,PF_CODE
    ,AGE
    ,HIGH AS AMT
    ,"高校" AS KIND 
    ,"3" AS KINDID
FROM ENROLLMENT_STATUS
UNION ALL
SELECT 
    SURVEY_YEAR
    ,PF_CODE
    ,AGE
    ,JUNIOR_CLG AS AMT
    ,"短大" AS KIND 
    ,"4" AS KINDID
FROM ENROLLMENT_STATUS
UNION ALL
SELECT 
    SURVEY_YEAR
    ,PF_CODE
    ,AGE
    ,COLLEGE AS AMT
    ,"大学" AS KIND 
    ,"5" AS KINDID
FROM ENROLLMENT_STATUS
UNION ALL
SELECT 
    SURVEY_YEAR
    ,PF_CODE
    ,AGE
    ,GRADUATE AS AMT
    ,"大学院" AS KIND 
    ,"6" AS KINDID
FROM ENROLLMENT_STATUS
) A
INNER JOIN PREFECTURE PRE
ON A.PF_CODE =PRE.PF_CODE
WHERE SURVEY_YEAR ="2020" and AMT not null 
GROUP BY     
    SURVEY_YEAR
    ,PF_NAME
    ,KIND
ORDER BY A.PF_CODE ASC, KINDID ASC
提出情報
提出日時2023/02/02 20:54:36
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者marumaruxxx
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
79 MB
データパターン2
WA
76 MB