ソースコード
SELECT
  '2020' SV_YEAR
  , PR.PF_NAME
  , PF.KIND
  , PF.AMT
FROM

(
SELECT
 PF_CODE
 , SUM(ELEMENTARY) AMT
 , '小学校' KIND
 , 1 as num
FROM
 ENROLLMENT_STATUS
WHERE
 SURVEY_YEAR = '2020'
GROUP BY
 PF_CODE
UNION
SELECT
 PF_CODE
 , SUM(MIDDLE) AMT
 , '中学校' KIND
 , 2 as num
FROM
 ENROLLMENT_STATUS
WHERE
 SURVEY_YEAR = '2020'
GROUP BY
 PF_CODE
UNION
SELECT
 PF_CODE
 , SUM(HIGH) AMT
 , '高校' KIND
 , 3 as num
FROM
 ENROLLMENT_STATUS
WHERE
 SURVEY_YEAR = '2020'
GROUP BY
 PF_CODE
UNION
SELECT
 PF_CODE
 , SUM(JUNIOR_CLG) AMT
 , '短大' KIND
 , 4 as num
FROM
 ENROLLMENT_STATUS
WHERE
 SURVEY_YEAR = '2020'
GROUP BY
 PF_CODE
UNION
SELECT
 PF_CODE
 , SUM(COLLEGE) AMT	
 , '大学' KIND
 , 5 as num
FROM
 ENROLLMENT_STATUS
WHERE
 SURVEY_YEAR = '2020'
GROUP BY
 PF_CODE
UNION
SELECT
 PF_CODE
 , SUM(GRADUATE) AMT
 , '大学院' KIND
 , 6 as num
FROM
 ENROLLMENT_STATUS
WHERE
 SURVEY_YEAR = '2020'
GROUP BY
 PF_CODE
) PF
INNER JOIN PREFECTURE PR on PR.PF_CODE = PF.PF_CODE
WHERE
  PF.AMT is not NULL
ORDER BY
  PF.PF_CODE
  , PF.num
;
提出情報
提出日時2022/09/21 22:00:34
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者udo
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量94 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
81 MB
データパターン2
WA
94 MB