ソースコード
select
    *
from (
    select
        2020 as SV_YEAR, pf_name as "PREFECTURE", sc as KIND, sum(z.cnt) as AMT
    from (
        select
            pf_code,小学校 as sc, elementary as cnt
        from (
            select pf_code, "小学校", ELEMENTARY from ENROLLMENT_STATUS where survey_year=2020
            union all
            select pf_code, "中学校", MIDDLE from ENROLLMENT_STATUS where survey_year=2020
            union all
            select pf_code, "高校", 	HIGH from ENROLLMENT_STATUS where survey_year=2020
            union all
            select pf_code, "短大", JUNIOR_CLG from ENROLLMENT_STATUS where survey_year=2020
            union all
            select pf_code, "大学", 	COLLEGE from ENROLLMENT_STATUS where survey_year=2020
            union all
            select pf_code, "大学院", 	GRADUATE from ENROLLMENT_STATUS where survey_year=2020
        )
    ) as z inner join PREFECTURE as p on z.PF_CODE=p.PF_CODE
    group by p.pf_code, sc
    order by p.pf_code asc,
        case sc
        when "小学校" then 1
        when "中学校" then 2
        when "高校" then 3
        when "短大" then 4
        when "大学" then 5
        else 6 end
) as t
where t.amt is not null
;



提出情報
提出日時2023/04/09 15:35:58
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者tabr
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
78 MB
データパターン2
AC
76 MB