ソースコード
with t as (
    select
        t.PF_CODE
        ,p.PF_NAME
        ,SUM(t.AMT) as total
    from
        DRINK_HABITS as t
    inner join PREFECTURE as p
        on t.PF_CODE = p.PF_CODE 
    where
        CATEGORY_CODE = '110'
    group by
        t.PF_CODE
), d as (
    select
        PF_CODE
        ,SUM(AMT) as sum
    from
        DRINK_HABITS
    where
        CATEGORY_CODE = '120'
        and GENDER_CODE in ('2','3')
    group by
        PF_CODE
)

select
    t.PF_CODE as CODE
    ,t.PF_NAME as NAME
    ,round((cast(d.sum AS REAL) /cast(t.total AS REAL)) *100 ,1) as PERCENTAGE
from
    t
inner join d
    on t.PF_CODE = d.PF_CODE
order by
    PERCENTAGE desc
    ,t.PF_CODE desc
提出情報
提出日時2023/07/05 16:33:00
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者mywk
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量87 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
87 MB