ソースコード
with tmp_kind as (
    select '小学校' as KIND
    union all select '中学校' as KIND
    union all select '高校' as KIND
    union all select '短大' as KIND
    union all select '大学' as KIND
    union all select '大学院' as KIND
)
select
    t1.SV_YEAR,
    t1.PREFECTURE,
    t2.KIND,
    sum(case t2.KIND
        when '小学校' then t1.ELEMENTARY
        when '中学校' then t1.MIDDLE
        when '高校' then t1.HIGH
        when '短大' then t1.JUNIOR_CLG
        when '大学' then t1.COLLEGE
        when '大学院' then t1.GRADUATE
    end) as AMT
from
    (
        select
            t1.SURVEY_YEAR as SV_YEAR,
            t2.PF_NAME as PREFECTURE,
            sum(t1.ELEMENTARY) as ELEMENTARY,
            sum(t1.MIDDLE) as MIDDLE,
            sum(t1.HIGH) as HIGH,
            sum(t1.JUNIOR_CLG) as JUNIOR_CLG,
            sum(t1.COLLEGE) as COLLEGE,
            sum(t1.GRADUATE) as GRADUATE
        from
            ENROLLMENT_STATUS t1
        inner join
            PREFECTURE t2
            on t1.PF_CODE = t2.PF_CODE
        where
            t1.SURVEY_YEAR = '2020'
        group by 1,2
    ) t1
cross join
    tmp_kind t2
group by 1,2,3
having AMT is not null;
提出情報
提出日時2022/09/21 15:41:47
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者s.ogata
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量93 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
93 MB
データパターン2
WA
93 MB