ソースコード
with table_a as (select SURVEY_YEAR as SV_YEAR, PF_NAME as PREFECTURE,PF_CODE, sum(ELEMENTARY) as a , sum(MIDDLE) as b, sum(HIGH) as c, sum(JUNIOR_CLG) as d, sum(COLLEGE) as e, sum(GRADUATE) as f
from ENROLLMENT_STATUS
left join PREFECTURE using (PF_CODE)
where SURVEY_YEAR = 2020
group by PF_CODE)

select SV_YEAR, PREFECTURE,KIND,AMT from 
(
select SV_YEAR, PREFECTURE,PF_CODE, "小学校" as KIND, a as AMT  from table_a where a > 0
union all
select SV_YEAR, PREFECTURE,PF_CODE, "中学校" as KIND, b as AMT  from table_a where b > 0
union all
select SV_YEAR, PREFECTURE,PF_CODE, "高校" as KIND, c as AMT  from table_a where c > 0
union all
select SV_YEAR, PREFECTURE,PF_CODE, "短大" as KIND, d as AMT  from table_a where d > 0
union all
select SV_YEAR, PREFECTURE,PF_CODE, "大学" as KIND, e as AMT  from table_a where e > 0
union all
select SV_YEAR, PREFECTURE,PF_CODE, "大学院" as KIND, f as AMT  from table_a where f > 0
)
order by PF_CODE
提出情報
提出日時2022/09/21 21:35:02
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者Tomii9273
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量100 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
100 MB
データパターン2
AC
92 MB