ソースコード
with cte as (select
pf_code,
sum(elementary) as "elementary",
sum(middle) as "middle",
sum(high) as "high",
sum(junior_clg) as "junior_clg",
sum(college) as "college",
sum(graduate) as "graduate"
from
enrollment_status
where
survey_year = 2020
group by 
pf_code
)
select
2020 as "SV_YEAR",
p.pf_name as "PREFECTURE",
"KIND",
"AMT"
from 
(
select pf_code, "小学校" as "KIND", "elementary" as "AMT", 1 as "sortkey" from cte
union all
select pf_code, "中学校" as "KIND", "middle" as "AMT", 2 as "sortkey" from cte
union all
select pf_code, "高校" as "KIND", "high" as "AMT", 3 as "sortkey" from cte
union all
select pf_code, "短大" as "KIND", "junior_clg" as "AMT", 4 as "sortkey" from cte
union all
select pf_code, "大学" as "KIND", "college" as "AMT", 5 as "sortkey" from cte
union all
select pf_code, "大学院" as "KIND", "graduate" as "AMT", 6 as "sortkey" from cte
) s
inner join PREFECTURE p
on s.pf_code = p.pf_code
where
"AMT" is not null
order by
 s.pf_code asc,
 sortkey asc
提出情報
提出日時2022/09/22 02:13:59
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者Reliability
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
88 MB
データパターン2
AC
80 MB