ソースコード
SELECT 
  TMP.SURVEY_YEAR AS SV_YEAR,
  TMP.PF_NAME AS PREFECTURE, 
  TMP.KIND_NAME AS KIND,
  SUM(TMP.AMT) AS AMT
FROM (
  SELECT 
    SURVEY_YEAR,
    PF.PF_CODE, 
    PF.PF_NAME,
    KIND_CODE,
    KIND_NAME,
    AMT
  FROM
    (
    SELECT SURVEY_YEAR,
    PF_CODE,
    1 AS KIND_CODE,
    '小学校' AS KIND_NAME,
    ELEMENTARY AS AMT FROM ENROLLMENT_STATUS WHERE ELEMENTARY IS NOT NULL AND SURVEY_YEAR = 2020
    UNION
    SELECT SURVEY_YEAR,
    PF_CODE,
    2 AS KIND_CODE,
    '中学校' AS KIND_NAME,
    MIDDLE AS AMT FROM ENROLLMENT_STATUS WHERE MIDDLE IS NOT NULL AND SURVEY_YEAR = 2020
    UNION
    SELECT SURVEY_YEAR,
    PF_CODE,
    3 AS KIND_CODE,
    '高校' AS KIND_NAME,
    HIGH AS AMT FROM ENROLLMENT_STATUS WHERE HIGH IS NOT NULL AND SURVEY_YEAR = 2020
    UNION
    SELECT SURVEY_YEAR,
    PF_CODE,
    4 AS KIND_CODE,
    '短大' AS KIND_NAME,
    JUNIOR_CLG AS AMT FROM ENROLLMENT_STATUS WHERE JUNIOR_CLG IS NOT NULL AND SURVEY_YEAR = 2020
    UNION
    SELECT SURVEY_YEAR,
    PF_CODE,
    5 AS KIND_CODE,
    '大学' AS KIND_NAME,
    COLLEGE AS AMT FROM ENROLLMENT_STATUS WHERE COLLEGE IS NOT NULL AND SURVEY_YEAR = 2020
    UNION
    SELECT SURVEY_YEAR,
    PF_CODE,
    6 AS KIND_CODE,
    '大学院' AS KIND_NAME,
    GRADUATE AS AMT FROM ENROLLMENT_STATUS WHERE GRADUATE IS NOT NULL AND SURVEY_YEAR = 2020
  ) TM LEFT OUTER JOIN PREFECTURE PF ON TM.PF_CODE = PF.PF_CODE
) TMP
where
    AMT is not NULL
GROUP BY TMP.SURVEY_YEAR,
  TMP.PF_NAME, 
  TMP.KIND_NAME
ORDER BY TMP.PF_CODE, TMP.KIND_CODE
提出情報
提出日時2023/02/19 17:25:21
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者kazuya030
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量98 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
98 MB
データパターン2
WA
80 MB