コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
with syo as (
select PF_CODE,SURVEY_YEAR,sum(ELEMENTARY) as AMT,'小学校' as KIND, 1 as odr
from ENROLLMENT_STATUS
where SURVEY_YEAR = 2020 and ELEMENTARY is not null
group by PF_CODE
)
,chu as (
select PF_CODE,SURVEY_YEAR,sum(MIDDLE) as AMT,'中学校' as KIND, 2 as odr
from ENROLLMENT_STATUS
where SURVEY_YEAR = 2020 and MIDDLE is not null
group by PF_CODE
)
,koko as (
select PF_CODE,SURVEY_YEAR,sum(HIGH) as AMT,'高校' as KIND, 3 as odr
from ENROLLMENT_STATUS
where SURVEY_YEAR = 2020 and HIGH is not null
group by PF_CODE
)
,tan as (
select PF_CODE,SURVEY_YEAR,sum(JUNIOR_CLG) as AMT,'短大' as KIND, 4 as odr
from ENROLLMENT_STATUS
where SURVEY_YEAR = 2020 and JUNIOR_CLG is not null
group by PF_CODE
)
,dai as (
select PF_CODE,SURVEY_YEAR,sum(COLLEGE) as AMT,'大学' as KIND, 5 as odr
from ENROLLMENT_STATUS
where SURVEY_YEAR = 2020 and COLLEGE is not null
group by PF_CODE
)
,daiga as (
select PF_CODE,SURVEY_YEAR,sum(GRADUATE) as AMT,'大学院' as KIND, 6 as odr
from ENROLLMENT_STATUS
where SURVEY_YEAR = 2020 and GRADUATE is not null
group by PF_CODE
)
select
kin.SURVEY_YEAR as SV_YEAR
,pr.PF_NAME as PREFECTURE
,kin.kind as KIND
,kin.AMT as AMT
from
PREFECTURE pr
,(
select * from syo union all
select * from chu union all
select * from koko union all
select * from tan union all
select * from dai union all
select * from daiga
) kin
where
pr.PF_CODE = kin.PF_CODE
order by
pr.PF_CODE
,kin.odr
;
提出情報
提出日時 | 2022/09/22 13:31:14 |
コンテスト | 第2回 SQLコンテスト |
問題 | 就学状況の表示変換 |
受験者 | idakazoo |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 78 MB |
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
78 MB
データパターン2
AC
76 MB