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