ソースコード
with 
tbl1 as(
select
SURVEY_YEAR
,PF_CODE
,sum(ELEMENTARY) as EL
,sum(MIDDLE) as MI
,sum(HIGH) as HI
,sum(JUNIOR_CLG) as JU
,sum(COLLEGE) as CO
,sum(GRADUATE) as GR
from ENROLLMENT_STATUS
where SURVEY_YEAR=2020
group by PF_CODE
order by PF_CODE asc
)
,tbl2 as(
select SURVEY_YEAR as SV_YEAR,PF_CODE,1 as NUM,EL as AMT from tbl1
union all
select SURVEY_YEAR,PF_CODE,2,MI from tbl1
union all
select SURVEY_YEAR,PF_CODE,3,HI from tbl1
union all
select SURVEY_YEAR,PF_CODE,4,JU from tbl1
union all
select SURVEY_YEAR,PF_CODE,5,CO from tbl1
union all
select SURVEY_YEAR,PF_CODE,6,GR from tbl1
)
select
SV_YEAR
,PF_NAME
,case NUM when 1 then '小学校' 
        when 2 then '中学校' 
        when 3 then '高校' 
        when 4 then '短大' 
        when 5 then '大学' 
        when 6 then '大学院' end as KIND
,AMT
from tbl2
inner join PREFECTURE PR on tbl2.PF_CODE =PR.PF_CODE
where AMT is not NULL
order by tbl2.PF_CODE asc,NUM asc
提出情報
提出日時2023/10/04 14:13:08
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者abcdefghijklmnopqrstuvwxy
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
79 MB
データパターン2
WA
77 MB