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