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