ソースコード
with
es as (
    select
        *
    from
        ENROLLMENT_STATUS
    where
        survey_year = "2020"
)

select
    survey_year as SV_YEAR,
    pf_name as PREFECTURE,
    KIND,
    AMT

from (
    select
        survey_year,
        pf_code,
        1 as num,
        "小学校" as KIND,
        sum(elementary) as AMT
    from 
        es 
    group by
        survey_year,
        pf_code
    
    union all
    select
        survey_year,
        pf_code,
        2 as num,

        "中学校" as KIND,
        sum(middle) as AMT
    from 
        es 
    group by
        survey_year,
        pf_code

    union all
    
    select
        survey_year,
        pf_code,
        3 as num,
        "高校" as KIND,
        sum(high) as AMT
    from 
        es 
    group by
        survey_year,
        pf_code

    union all

    select
        survey_year,
        pf_code,
        4 as num,
        "短大" as KIND,
        sum(junior_clg) as AMT
    from 
        es 
    group by
        survey_year,
        pf_code

    union all

    select
        survey_year,
        pf_code,
        5 as num,
        "大学" as KIND,
        sum(college) as AMT
    from 
        es 
    group by
        survey_year,
        pf_code
    union all

    select
        survey_year,
        pf_code,
        6 as num,
        "大学院" as KIND,
        sum(graduate) as AMT
    from 
        es 
    group by
        survey_year,
        pf_code

) as ee
left outer join
    prefecture
on
    ee.pf_code = prefecture.pf_code
where
    amt is not null
order by
    ee.pf_code,
    num
提出情報
提出日時2022/09/21 14:32:28
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者koya_346
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量95 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
95 MB
データパターン2
AC
76 MB