ソースコード
select
    TBL1.PF_CODE as CODE,
    TBL2.PF_NAME as NAME,
    round(sum(
        case when TBL1.col1 = '120' then cast(TBL1.total_AMT as REAL)
        else cast(0 as REAL) end)
        /
    sum(case when TBL1.col1 = '110' then cast(TBL1.total_AMT as REAL)
        else cast(0 as REAL) end
    )*100,2) as PERCENTAGE
from(
    select '110' as col1,PF_CODE,sum(AMT) as total_AMT
    from DRINK_HABITS
    where (GENDER_CODE = '2' or GENDER_CODE = '3') and CATEGORY_CODE = '110'
    group by PF_CODE
    
    union
    
    select '120' as col1,PF_CODE,sum(AMT) as total_AMT
    from DRINK_HABITS
    where (GENDER_CODE = '2' or GENDER_CODE = '3') and CATEGORY_CODE = '120'
    group by PF_CODE
) as TBL1
left outer join PREFECTURE as TBL2 on TBL1.PF_CODE=TBL2.PF_CODE
where total_AMT <> 0
group by TBL1.PF_CODE,TBL2.PF_NAME
order by 3,1
提出情報
提出日時2022/10/25 14:52:41
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者M_ENDO
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
80 MB
データパターン2
WA
78 MB