ソースコード
select
a.SURVEY_YEAR as SV_YEAR
, p.pf_name as PREFECTURE
, KIND
, a.sum as AMT
from
(
select e.SURVEY_YEAR, e.pf_code, '小学校' KIND, sum(e.elementary) SUM from ENROLLMENT_STATUS e where e.survey_year = '2020' group by e.SURVEY_YEAR, e.pf_code
union all
select e.SURVEY_YEAR, e.pf_code, '中学校' KIND, sum(e.MIDDLE) SUM from ENROLLMENT_STATUS e where e.survey_year = '2020' group by e.SURVEY_YEAR, e.pf_code
union all
select e.SURVEY_YEAR, e.pf_code, '高校' KIND, sum(e.HIGH) SUM from ENROLLMENT_STATUS e where e.survey_year = '2020' group by e.SURVEY_YEAR, e.pf_code
union all
select e.SURVEY_YEAR, e.pf_code, '短大' KIND, sum(e.JUNIOR_CLG) SUM from ENROLLMENT_STATUS e where e.survey_year = '2020' group by e.SURVEY_YEAR, e.pf_code
union all
select e.SURVEY_YEAR, e.pf_code, '大学' KIND, sum(e.COLLEGE) SUM from ENROLLMENT_STATUS e where e.survey_year = '2020' group by e.SURVEY_YEAR, e.pf_code
union all
select e.SURVEY_YEAR, e.pf_code, '大学院' KIND, sum(e.GRADUATE) SUM from ENROLLMENT_STATUS e where e.survey_year = '2020' group by e.SURVEY_YEAR, e.pf_code
)a
join PREFECTURE p on a.pf_code = p.pf_code
where a.sum is not null
order by p.pf_code, KIND='小学校' desc, KIND='中学校' desc, KIND='高校' desc, KIND='短大' desc, KIND='大学' desc
提出情報
提出日時2024/07/29 15:03:25
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者marina
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量88 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
88 MB
データパターン2
AC
84 MB