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