ソースコード
with population as (
    select
        sum(case when category_code = '110' then amt else 0 end) as total,
        sum(case when category_code = '120' then amt else 0 end) as drink,
        pf_code
    from
        drink_habits
    where
        gender_code in ('2', '3')
    group by
        pf_code
)
select
    population.pf_code as CODE,
    prefecture.pf_name as NAME,
    round(100.0 * population.drink / population.total, 1) as PERCENTAGE
from
    population
inner join
    prefecture
    on prefecture.pf_code = population.pf_code
order by
    percentage desc,
    code desc
;
提出情報
提出日時2022/12/11 13:01:00
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者tekihei2317
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
AC
79 MB