ソースコード
SELECT ES.SURVEY_YEAR,
       ES.PF_NAME,
       CASE b.SEQ_NO 
         WHEN 1 THEN '小学校' 
         WHEN 2 THEN '中学校' 
         WHEN 3 THEN '高校' 
         WHEN 4 THEN '短大' 
         WHEN 5 THEN '大学' 
         WHEN 6 THEN '大学院' 
         ELSE NULL 
         END AS KIND,
       CASE b.SEQ_NO 
         WHEN 1 THEN ES.ELEMENTARY 
         WHEN 2 THEN ES.MIDDLE 
         WHEN 3 THEN ES.HIGH 
         WHEN 4 THEN ES.JUNIOR_CLG 
         WHEN 5 THEN ES.COLLEGE 
         WHEN 6 THEN ES.GRADUATE 
         ELSE NULL 
         END AS AMOUNT 
  FROM (SELECT E.SURVEY_YEAR,
               E.PF_CODE,
               P.PF_NAME,
               SUM(ifnull(E.ELEMENTARY, 0)) AS ELEMENTARY,
               SUM(ifnull(E.MIDDLE, 0)) AS MIDDLE,
               SUM(ifnull(E.HIGH, 0)) AS HIGH,
               SUM(ifnull(E.JUNIOR_CLG, 0)) AS JUNIOR_CLG,
               SUM(ifnull(E.COLLEGE, 0)) AS COLLEGE,
               SUM(ifnull(E.GRADUATE, 0)) AS GRADUATE
          FROM ENROLLMENT_STATUS E
          LEFT JOIN PREFECTURE P
            ON E.PF_CODE = P.PF_CODE
         WHERE SURVEY_YEAR = '2020'
         GROUP BY E.SURVEY_YEAR,
                  E.PF_CODE
         ORDER BY E.PF_CODE
        )ES
  CROSS JOIN (SELECT 1 AS SEQ_NO  
               UNION ALL
              SELECT 2 AS SEQ_NO  
               UNION ALL
              SELECT 3 AS SEQ_NO  
               UNION ALL
              SELECT 4 AS SEQ_NO  
               UNION ALL
              SELECT 5 AS SEQ_NO  
               UNION ALL
              SELECT 6 AS SEQ_NO  
              ) AS b      
  WHERE AMOUNT != 0
提出情報
提出日時2023/07/28 15:20:11
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者test
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量96 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
96 MB
データパターン2
WA
96 MB