ソースコード
SELECT
  a.survey_year,
  b.pf_name,
  a.kind,
  a.amt
FROM
  (
    SELECT
      survey_year,
      pf_code,
      sum(elementary) AS amt,
      '小学校' AS "kind",
      1 AS "seq"
    FROM
      enrollment_status
    WHERE
      survey_year = 2020
    GROUP BY
      pf_code
    UNION ALL
    SELECT
      survey_year,
      pf_code,
      sum(middle),
      '中学校' AS "kind",
      2 AS "seq"
    FROM
      enrollment_status
    WHERE
      survey_year = 2020
    GROUP BY
      pf_code
    UNION ALL
    SELECT
      survey_year,
      pf_code,
      sum(high),
      '高校' AS "kind",
      3 AS "seq"
    FROM
      enrollment_status
    WHERE
      survey_year = 2020
    GROUP BY
      pf_code
    UNION ALL
    SELECT
      survey_year,
      pf_code,
      sum(junior_clg),
      '短大' AS "kind",
      4 AS "seq"
    FROM
      enrollment_status
    WHERE
      survey_year = 2020
    GROUP BY
      pf_code
    UNION ALL
    SELECT
      survey_year,
      pf_code,
      sum(college),
      '大学' AS "kind",
      5 AS "seq"
    FROM
      enrollment_status
    WHERE
      survey_year = 2020
    GROUP BY
      pf_code
    UNION ALL
    SELECT
      survey_year,
      pf_code,
      sum(graduate),
      '大学院' AS "kind",
      6 AS "seq"
    FROM
      enrollment_status
    WHERE
      survey_year = 2020
    GROUP BY
      pf_code
  ) a
  JOIN prefecture b ON a.pf_code = b.pf_code
WHERE
  a.amt IS NOT NULL
ORDER BY
  a.pf_code,
  a."seq";
提出情報
提出日時2022/09/24 22:34:25
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者SKT0205
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
78 MB
データパターン2
WA
76 MB