ソースコード

with t as (
  SELECT * FROM ENROLLMENT_STATUS WHERE SURVEY_YEAR = 2020
)
,piv as (
  SELECT SURVEY_YEAR, pf_code, 1 as n, '小学校' as KIND, SUM(ELEMENTARY) as AMT FROM t GROUP BY SURVEY_YEAR, pf_code
  UNION ALL
  SELECT SURVEY_YEAR, pf_code, 2 as n, '中学校' as KIND, SUM(MIDDLE) as AMT FROM t GROUP BY SURVEY_YEAR, pf_code
  UNION ALL
  SELECT SURVEY_YEAR, pf_code, 3 as n, '高校校' as KIND, SUM(HIGH) as AMT FROM t GROUP BY SURVEY_YEAR, pf_code
  UNION ALL
  SELECT SURVEY_YEAR, pf_code, 4 as n, '短大' as KIND, SUM(JUNIOR_CLG) as AMT FROM t GROUP BY SURVEY_YEAR, pf_code
  UNION ALL
  SELECT SURVEY_YEAR, pf_code, 5 as n, '大学' as KIND, SUM(COLLEGE) as AMT FROM t GROUP BY SURVEY_YEAR, pf_code
  UNION ALL
  SELECT SURVEY_YEAR, pf_code, 6 as n, '大学院' as KIND, SUM(GRADUATE) as AMT FROM t GROUP BY SURVEY_YEAR, pf_code
)
SELECT
A.SURVEY_YEAR AS SV_YEAR
,b.PF_NAME AS PREFECTURE
,A.KIND
,A.AMT
FROM
piv A
inner join
prefecture B 
USING (pf_code)
WHERE
A.AMT IS NOT NULL
ORDER BY
A.PF_CODE asc
,A.n asc
;
提出情報
提出日時2023/05/16 14:47:18
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者masashi_sql
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
78 MB
データパターン2
WA
78 MB