コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
with tbl as (
select
es.survey_year,
p.pf_name,
sum(case when elementary is not null then elementary else 0 end) as 'amt_e',
sum(case when middle is not null then middle else 0 end) as 'amt_m',
sum(case when high is not null then high else 0 end) as 'amt_h',
sum(case when junior_clg is not null then junior_clg else 0 end) as 'amt_j',
sum(case when college is not null then college else 0 end) as 'amt_c',
sum(case when graduate is not null then graduate else 0 end) as 'amt_g'
from ENROLLMENT_STATUS es
join PREFECTURE p on es.pf_code = p.pf_code
where es.survey_year = 2020
group by es.pf_code
),
union_tbl as (
select
survey_year as 'SV_YEAR',
pf_name as 'PREFECTURE',
'小学校' as 'KIND',
amt_e as 'AMT'
from tbl
union all
select
survey_year as 'SV_YEAR',
pf_name as 'PREFECTURE',
'中学校' as 'KIND',
amt_m as 'AMT'
from tbl
union all
select
survey_year as 'SV_YEAR',
pf_name as 'PREFECTURE',
'高校' as 'KIND',
amt_h as 'AMT'
from tbl
union all
select
survey_year as 'SV_YEAR',
pf_name as 'PREFECTURE',
'短大' as 'KIND',
amt_j as 'AMT'
from tbl
union all
select
survey_year as 'SV_YEAR',
pf_name as 'PREFECTURE',
'大学' as 'KIND',
amt_c as 'AMT'
from tbl
union all
select
survey_year as 'SV_YEAR',
pf_name as 'PREFECTURE',
'大学院' as 'KIND',
amt_g as 'AMT'
from tbl
)
select *
from tbl;
-- select *
-- from union_tbl
-- where AMT <> 0
-- order by 2 asc
提出情報
提出日時 | 2022/11/26 12:42:24 |
コンテスト | 第2回 SQLコンテスト |
問題 | 就学状況の表示変換 |
受験者 | nhsykym |
状態 (詳細) | WA (Wrong Answer: 誤答) |
メモリ使用量 | 82 MB |
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
82 MB
データパターン2
WA
78 MB