ソースコード
select
    SURVEY_YEAR as SV_YEAR
    , PF_NAME as PREFECTURE
    , KIND
    , sum(AMT) as AMT

from 
(    (select
        SURVEY_YEAR
        , PF_CODE
        , '小学校' as KIND
        , 1 as hoge
        , ELEMENTARY as AMT
    from ENROLLMENT_STATUS
    where SURVEY_YEAR = 2020 and ELEMENTARY is not NULL)
    
    union all
    
    (select
        SURVEY_YEAR
        , PF_CODE
        , '中学校' as KIND
        , 2 as hoge
        , MIDDLE as AMT
    from ENROLLMENT_STATUS
    where SURVEY_YEAR = 2020 and MIDDLE is not NULL)

    union all
    
    (select
        SURVEY_YEAR
        , PF_CODE
        , '高校' as KIND
        , 3 as hoge
        , HIGH as AMT
    from ENROLLMENT_STATUS
    where SURVEY_YEAR = 2020 and HIGH is not NULL)
    
    union all
    
    (select
        SURVEY_YEAR
        , PF_CODE
        , '短大' as KIND
        , 4 as hoge
        , JUNIOR_CLG as AMT
    from ENROLLMENT_STATUS
    where SURVEY_YEAR = 2020 and JUNIOR_CLG is not NULL)
    
     union all
    
    (select
        SURVEY_YEAR
        , PF_CODE
        , '大学' as KIND
        , 5 as hoge
        , COLLEGE as AMT
    from ENROLLMENT_STATUS
    where SURVEY_YEAR = 2020 and COLLEGE is not NULL)
    
     union all
    
    (select
        SURVEY_YEAR
        , PF_CODE
        , '大学院' as KIND
        , 6 as hoge
        , GRADUATE as AMT
    from ENROLLMENT_STATUS
    where SURVEY_YEAR = 2020 and GRADUATE is not NULL) 
) inner join PREFECTURE
    using(PF_CODE)
    
order by 
 PF_CODE, hoge
 
    
提出情報
提出日時2022/09/22 00:06:28
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者Udwei22
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量94 MB
メッセージ
SQLITE_ERROR: near "union": syntax error
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
94 MB
データパターン2
RE
78 MB