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