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