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