ソースコード
WITH A as (
    select PF_CODE, sum(AMT) as AMT1
    from DRINK_HABITS
    where GENDER_CODE in ('2', '3') and CATEGORY_CODE == 110
    group by PF_CODE
),
B as (
    select PF_CODE, sum(AMT) as AMT2
    from DRINK_HABITS
    where GENDER_CODE in ('2', '3') and CATEGORY_CODE == 120
    group by PF_CODE
)

select A.PF_CODE as CODE, PF_NAME as NAME, ROUND(100.0 * B.AMT2 / A.AMT1, 1) as PERCENTAGE
from A 
    join B on A.PF_CODE = B.PF_CODE 
    left join  PREFECTURE on A.PF_CODE = PREFECTURE.PF_CODE
ORDER BY PERCENTAGE desc, code desc

提出情報
提出日時2022/11/16 11:33:40
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者warya
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
81 MB
データパターン2
AC
81 MB