コンテストの制限時間が終了しました。
以降も提出を行うことができますが、順位集計には反映されません。
以降も提出を行うことができますが、順位集計には反映されません。
ソースコード
SELECT
SV_YEAR
,PREFECTURE
,KIND
,AMT
FROM (
SELECT
ENR.SURVEY_YEAR AS SV_YEAR
,ENR.PF_CODE AS CODE
,PRE.PF_NAME AS PREFECTURE
,1 KINDNO
,'小学校'KIND
,SUM(ELEMENTARY)AMT
FROM ENROLLMENT_STATUS ENR
LEFT JOIN PREFECTURE PRE
ON ENR.PF_CODE = PRE.PF_CODE
WHERE ENR.SURVEY_YEAR = 2020
AND ENR.ELEMENTARY IS NOT NULL
GROUP BY ENR.SURVEY_YEAR
,PRE.PF_NAME
UNION
SELECT
ENR.SURVEY_YEAR AS SV_YEAR
,ENR.PF_CODE AS CODE
,PRE.PF_NAME AS PREFECTURE
,2 KINDNO
,'中学校'KIND
,SUM(MIDDLE)AMT
FROM ENROLLMENT_STATUS ENR
LEFT JOIN PREFECTURE PRE
ON ENR.PF_CODE = PRE.PF_CODE
WHERE ENR.SURVEY_YEAR = 2020
AND ENR.MIDDLE IS NOT NULL
GROUP BY ENR.SURVEY_YEAR
,PRE.PF_NAME
UNION
SELECT
ENR.SURVEY_YEAR AS SV_YEAR
,ENR.PF_CODE AS CODE
,PRE.PF_NAME AS PREFECTURE
,3 KINDNO
,'高校'KIND
,SUM(HIGH)AMT
FROM ENROLLMENT_STATUS ENR
LEFT JOIN PREFECTURE PRE
ON ENR.PF_CODE = PRE.PF_CODE
WHERE ENR.SURVEY_YEAR = 2020
AND ENR.HIGH IS NOT NULL
GROUP BY ENR.SURVEY_YEAR
,PRE.PF_NAME
UNION
SELECT
ENR.SURVEY_YEAR AS SV_YEAR
,ENR.PF_CODE AS CODE
,PRE.PF_NAME AS PREFECTURE
,4 KINDNO
,'短大'KIND
,SUM(JUNIOR_CLG)AMT
FROM ENROLLMENT_STATUS ENR
LEFT JOIN PREFECTURE PRE
ON ENR.PF_CODE = PRE.PF_CODE
WHERE ENR.SURVEY_YEAR = 2020
AND ENR.JUNIOR_CLG IS NOT NULL
GROUP BY ENR.SURVEY_YEAR
,PRE.PF_NAME
UNION
SELECT
ENR.SURVEY_YEAR AS SV_YEAR
,ENR.PF_CODE AS CODE
,PRE.PF_NAME AS PREFECTURE
,5 KINDNO
,'大学'KIND
,SUM(COLLEGE)AMT
FROM ENROLLMENT_STATUS ENR
LEFT JOIN PREFECTURE PRE
ON ENR.PF_CODE = PRE.PF_CODE
WHERE ENR.SURVEY_YEAR = 2020
AND ENR.COLLEGE IS NOT NULL
GROUP BY ENR.SURVEY_YEAR
,PRE.PF_NAME
UNION
SELECT
ENR.SURVEY_YEAR AS SV_YEAR
,ENR.PF_CODE AS CODE
,PRE.PF_NAME AS PREFECTURE
,6 KINDNO
,'大学院'KIND
,SUM(GRADUATE)AMT
FROM ENROLLMENT_STATUS ENR
LEFT JOIN PREFECTURE PRE
ON ENR.PF_CODE = PRE.PF_CODE
WHERE ENR.SURVEY_YEAR = 2020
AND ENR.GRADUATE IS NOT NULL
GROUP BY ENR.SURVEY_YEAR
,PRE.PF_NAME
)
ORDER BY CODE ASC
,KINDNO ASC
提出情報
提出日時 | 2022/09/21 17:01:55 |
コンテスト | 第2回 SQLコンテスト |
問題 | 就学状況の表示変換 |
受験者 | jojojojoo |
状態 (詳細) | AC (Accepted: 正答) |
メモリ使用量 | 86 MB |
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
86 MB
データパターン2
AC
79 MB