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