ソースコード
with t as (
    select e.PF_CODE, p.PF_NAME,
    coalesce(sum(ELEMENTARY),0) as s0,
    coalesce(sum(MIDDLE),0) as s1,
    coalesce(sum(HIGH),0) as s2,
    coalesce(sum(JUNIOR_CLG),0) as s3,
    coalesce(sum(COLLEGE),0) as s4,
    coalesce(sum(GRADUATE),0) as s5
    from ENROLLMENT_STATUS as e
    inner join PREFECTURE as p on p.PF_CODE=e.PF_CODE
    where e.survey_year=2020
    group by e.PF_CODE, p.PF_NAME
), u as (
    select 2020 as "SV_YEAR",
    pf_name as "PREFECTURE",
    "小学校" as "KIND",
    s0 as "AMT", PF_CODE, 0 as k
    from t
    union all
    select 2020 as "SV_YEAR",
    pf_name as "PREFECTURE",
    "中学校" as "KIND",
    s1 as "AMT", PF_CODE, 1 as k
    from t
    union all
    select 2020 as "SV_YEAR",
    pf_name as "PREFECTURE",
    "高校" as "KIND",
    s2 as "AMT", PF_CODE, 2 as k
    from t
    union all
    select 2020 as "SV_YEAR",
    pf_name as "PREFECTURE",
    "短大" as "KIND",
    s3 as "AMT", PF_CODE, 3 as k
    from t
    union all
    select 2020 as "SV_YEAR",
    pf_name as "PREFECTURE",
    "大学" as "KIND",
    s4 as "AMT", PF_CODE, 4 as k
    from t
    union all
    select 2020 as "SV_YEAR",
    pf_name as "PREFECTURE",
    "大学院" as "KIND",
    s5 as "AMT", PF_CODE, 5 as k
    from t
)
select SV_YEAR,PREFECTURE,KIND,AMT
from u
where AMT!=0
order by pf_code, k
提出情報
提出日時2023/04/15 16:56:50
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者tabr
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量94 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
94 MB
データパターン2
AC
93 MB