ソースコード
WITH
EL as (SELECT 
SURVEY_YEAR,
PF_CODE,
SUM(ELEMENTARY) AS AMT,
'小学校' AS KIND,
1 AS KIND_NUM
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = '2020'
GROUP BY SURVEY_YEAR, PF_CODE, KIND, KIND_NUM),

MIDDLE as (SELECT 
SURVEY_YEAR,
PF_CODE,
SUM(MIDDLE) AS AMT,
'中学校' AS KIND,
2 AS KIND_NUM
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = '2020'
GROUP BY SURVEY_YEAR, PF_CODE, KIND, KIND_NUM),

HIGH as (SELECT 
SURVEY_YEAR,
PF_CODE,
SUM(HIGH) AS AMT,
'高校' AS KIND,
3 AS KIND_NUM
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = '2020'
GROUP BY SURVEY_YEAR, PF_CODE, KIND, KIND_NUM),

JU_CO as (SELECT 
SURVEY_YEAR,
PF_CODE,
SUM(JUNIOR_CLG) AS AMT,
'短大' AS KIND,
4 AS KIND_NUM
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = '2020'
GROUP BY SURVEY_YEAR, PF_CODE, KIND, KIND_NUM),

CLG as (SELECT 
SURVEY_YEAR,
PF_CODE,
SUM(COLLEGE) AS AMT,
'短大' AS KIND,
5 AS KIND_NUM
FROM ENROLLMENT_STATUS
WHERE SURVEY_YEAR = '2020'
GROUP BY SURVEY_YEAR, PF_CODE, KIND, KIND_NUM)
SELECT
SURVEY_YEAR AS SV_YEAR,
PF_NAME AS PREFECTURE,
KIND,
AMT
FROM(
SELECT * FROM EL
UNION SELECT * FROM MIDDLE
UNION SELECT * FROM HIGH
UNION SELECT * FROM JU_CO
UNION SELECT * FROM CLG) AS tbl
JOIN PREFECTURE as pf
ON tbl.PF_CODE = pf.PF_CODE
WHERE AMT IS NOT NULL
ORDER BY tbl.PF_CODE, KIND_NUM
提出情報
提出日時2022/09/21 16:03:52
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者matsushiman
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量96 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
96 MB
データパターン2
WA
93 MB