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