ソースコード
SELECT
  SV_YEAR
 ,PREFECTURE
 ,KIND
 ,AMT
FROM
(SELECT
 1 as "order_by",
 a.PF_CODE,
 a.SURVEY_YEAR as "SV_YEAR"
 ,PF_NAME as "PREFECTURE"
 ,"小学校" as "KIND"
 ,COUNT(ELEMENTARY) as "AMT"
FROM
 ENROLLMENT_STATUS a,PREFECTURE b
WHERE
 a.PF_CODE = b.PF_CODE
 and a.SURVEY_YEAR = 2020
 and ELEMENTARY is not null
union
SELECT
 2 as "order_by",
 c.PF_CODE,
 c.SURVEY_YEAR as "SV_YEAR"
 ,PF_NAME as "PREFECTURE"
 ,"中学校" as "KIND"
 ,COUNT(MIDDLE) as "AMT"
FROM
 ENROLLMENT_STATUS c,PREFECTURE d
WHERE
 c.PF_CODE = d.PF_CODE
 and c.SURVEY_YEAR = 2020
 and MIDDLE is not null
union
SELECT
 3 as "order_by",
 c.PF_CODE,
 c.SURVEY_YEAR as "SV_YEAR"
 ,PF_NAME as "PREFECTURE"
 ,"高校" as "KIND"
 ,COUNT(HIGH) as "AMT"
FROM
 ENROLLMENT_STATUS c,PREFECTURE d
WHERE
 c.PF_CODE = d.PF_CODE
 and c.SURVEY_YEAR = 2020
 and HIGH is not null
 union
SELECT
 4 as "order_by",
 c.PF_CODE,
 c.SURVEY_YEAR as "SV_YEAR"
 ,PF_NAME as "PREFECTURE"
 ,"短大" as "KIND"
 ,COUNT(JUNIOR_CLG) as "AMT"
FROM
 ENROLLMENT_STATUS c,PREFECTURE d
WHERE
 c.PF_CODE = d.PF_CODE
 and c.SURVEY_YEAR = 2020
 and JUNIOR_CLG is not null
  union
SELECT
 5 as "order_by",
 c.PF_CODE,
 c.SURVEY_YEAR as "SV_YEAR"
 ,PF_NAME as "PREFECTURE"
 ,"大学" as "KIND"
 ,COUNT(COLLEGE) as "AMT"
FROM
 ENROLLMENT_STATUS c,PREFECTURE d
WHERE
 c.PF_CODE = d.PF_CODE
 and c.SURVEY_YEAR = 2020
 and COLLEGE is not null
   union
SELECT
 6 as "order_by",
 c.PF_CODE,
 c.SURVEY_YEAR as "SV_YEAR"
 ,PF_NAME as "PREFECTURE"
 ,"大学院" as "KIND"
 ,COUNT(GRADUATE) as "AMT"
FROM
 ENROLLMENT_STATUS c,PREFECTURE d
WHERE
 c.PF_CODE = d.PF_CODE
 and c.SURVEY_YEAR = 2020
 and GRADUATE is not null
 )
order by PF_CODE asc,order_by asc

提出情報
提出日時2022/09/22 00:26:09
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者O.I.
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量96 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
94 MB
データパターン2
WA
96 MB