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