ソースコード
select 2020    as SURVEY_YEAR,
       PF_NAME as PREFECTURE,
       case kind
           when 1 then '小学校'
           when 2 then '中学校'
           when 3 then '高校'
           when 4 then '短大'
           when 5 then '大学'
           when 6 then '大学院'
           end as KIND,
       sum(val) as AMT

from (with T1 as (select *, ELEMENTARY as val, 1 as kind
                  from ENROLLMENT_STATUS
                  where SURVEY_YEAR = 2020
                    and ELEMENTARY is not null),
           T2 as (select *, MIDDLE as val, 2 as kind
                  from ENROLLMENT_STATUS
                  where SURVEY_YEAR = 2020
                    and MIDDLE is not null),
           T3 as (select *, HIGH as val, 3 as kind
                  from ENROLLMENT_STATUS
                  where SURVEY_YEAR = 2020
                    and HIGH is not null),
           T4 as (select *, JUNIOR_CLG as val, 4 as kind
                  from ENROLLMENT_STATUS
                  where SURVEY_YEAR = 2020
                    and JUNIOR_CLG is not null),

           T5 as (select *, COLLEGE as val, 5 as kind
                  from ENROLLMENT_STATUS
                  where SURVEY_YEAR = 2020
                    and COLLEGE is not null),
           T6 as (select *, GRADUATE as val, 6 as kind
                  from ENROLLMENT_STATUS
                  where SURVEY_YEAR = 2020
                    and GRADUATE is not null)

      select *
      from T1
      union
      select *
      from T2
      union
      select *
      from T3
      union
      select *
      from T4
      union
      select *
      from T5
      union
      select *
      from T6) as t
         inner join PREFECTURE on PREFECTURE.pf_code = t.pf_code
group by t.pf_code, t.kind

order by PREFECTURE.pf_code, t.kind
提出情報
提出日時2023/02/20 08:18:14
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者tamurakami
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
81 MB
データパターン2
WA
78 MB