ソースコード
select
    DRINK_HABITS.PF_CODE as CODE, 
    PREFECTURE.PF_NAME as NAME, 
    -- sum(case when CATEGORY_CODE = '120' then AMT else 0 end) as DRINK, 
    -- sum(case when GENDER_CODE in (2, 3) then AMT else 0 end) as TOTAL23,
    -- sum(AMT) as TOTAL123, 
    round(cast(sum(case when (CATEGORY_CODE = '120' and GENDER_CODE in (2, 3)) then AMT else 0 end) * 100 as float) / sum(case when GENDER_CODE in (2, 3) then AMT else 0 end), 1) as PERCENTAGE
    -- round(cast(sum(case when CATEGORY_CODE = '120' then AMT else 0 end) * 100 as float) / sum(AMT), 1) as PERCENTAGE
    -- 都道府県毎の毎日飲酒率 as PERCENTAGE
from
    DRINK_HABITS
join PREFECTURE
    on (DRINK_HABITS.PF_CODE = PREFECTURE.PF_CODE)
group by
    NAME
order by
    PERCENTAGE desc, 
    CODE desc
-- having
--     GENDER_CODE in (2, 3);
提出情報
提出日時2022/09/22 11:42:01
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者Johann
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量94 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
81 MB
データパターン2
WA
94 MB