ソースコード
select 
    WK.SURVEY_YEAR as SV_YEAR
    ,a.PF_NAME as PREFECTURE
    ,wk.KIND as KIND
    ,wk.ANT as ANT
from 
    PREFECTURE a inner join 
    (
    select 	PF_CODE as PF_CODE,
            SURVEY_YEAR as SURVEY_YEAR,
            '1' as KIND,
            sum(ELEMENTARY) as ANT
    from ENROLLMENT_STATUS b
    where b.SURVEY_YEAR = '2020'
     and b.ELEMENTARY is not null and b.ELEMENTARY > 0
    union 
    select 	PF_CODE as PF_CODE,
            SURVEY_YEAR as SURVEY_YEAR,
            '2' as KIND,
            sum(MIDDLE) as ANT
    from ENROLLMENT_STATUS b
    where b.SURVEY_YEAR = '2020'
     and b.MIDDLE is not null and b.MIDDLE > 0
    union 
    select 	PF_CODE as PF_CODE,
            SURVEY_YEAR as SURVEY_YEAR,
            '3' as KIND,
            sum(HIGH) as ANT
    from ENROLLMENT_STATUS b
    where b.SURVEY_YEAR = '2020'
     and b.HIGH is not null and b.HIGH > 0
    union 
    select 	PF_CODE as PF_CODE,
            SURVEY_YEAR as SURVEY_YEAR,
            '4' as KIND,
            sum(JUNIOR_CLG) as ANT
    from ENROLLMENT_STATUS b
    where b.SURVEY_YEAR = '2020'
     and b.JUNIOR_CLG is not null and b.JUNIOR_CLG > 0
    union 
    select 	PF_CODE as PF_CODE,
            SURVEY_YEAR as SURVEY_YEAR,
            '5' as KIND,
            sum(COLLEGE) as ANT
    from ENROLLMENT_STATUS b
    where b.SURVEY_YEAR = '2020'
     and b.	COLLEGE is not null and b.COLLEGE > 0
    union 
    select 	PF_CODE as PF_CODE,
            SURVEY_YEAR as SURVEY_YEAR,
            '6' as KIND,
            sum(GRADUATE) as ANT
    from ENROLLMENT_STATUS b
    where b.SURVEY_YEAR = '2020'
     and b.	GRADUATE is not null and b.	GRADUATE > 0) WK
    on a.PF_CODE = wk.PF_CODE
order by 
    a.PF_NAME,
    WK.KIND
    
提出情報
提出日時2022/09/21 13:14:13
コンテスト第2回 SQLコンテスト
問題就学状況の表示変換
受験者12345
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
86 MB
データパターン2
WA
80 MB