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