ソースコード

SELECT
    SURVEY_YEAR,
    PF_NAME,
    SUM(ELEMENTARY) AS AMT,
    '小学校' AS KIND
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = 2020
JOIN PREFECTURE USING(PF_CODE)
GROUP BY 1,2
UNION
SELECT
    SURVEY_YEAR,
    PF_NAME,
    SUM(MIDDLE) AS AMT,
    '中学校' AS KIND
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = 2020
JOIN PREFECTURE USING(PF_CODE)
GROUP BY 1,2

UNION
SELECT
    SURVEY_YEAR,
     PF_NAME,
    SUM(HIGH) AS AMT,
    '高校' AS KIND
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = 2020
GROUP BY 1,2
UNION
SELECT
    SURVEY_YEAR,
    PF_NAME,
    SUM(JUNIOR_CLG) AS AMT,
    '短大' AS KIND
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = 2020
GROUP BY 1,2
UNION
SELECT
    SURVEY_YEAR,
    PF_NAME,
    SUM(COLLEGE) AS AMT,
    '大学' AS KIND
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = 2020
GROUP BY 1,2
UNION
SELECT
    SURVEY_YEAR,
    PF_NAME,
    SUM(GRADUATE) AS AMT,
    '大学院' AS KIND
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = 2020
GROUP BY 1,2


提出情報
提出日時2022/09/21 16:43:02
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者okamenatto
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量100 MB
メッセージ
SQLITE_ERROR: near "JOIN": syntax error
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
100 MB
データパターン2
RE
100 MB