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