ソースコード
select
    pref.pf_code as CODE
    , pref.pf_name as NAME
    , round(cast(everyday.amt as real) * 100 / total.amt, 1) as PERCENTAGE
from prefecture as pref
    inner join (
        select 
            pf_code
            , sum(amt) as amt
        from drink_habits
        where 
            category_code = '110'
            and gender_code in (2, 3)
        group by
            pf_code
    ) as total
        on pref.pf_code = total.pf_code
    inner join (
        select
            pf_code
            , sum(amt) as amt
        from drink_habits
        where 
            category_code = '120'
            and gender_code in (2, 3)
        group by
            pf_code
    ) as everyday
        on pref.pf_code = everyday.pf_code
order by 
    PERCENTAGE desc
    , CODE desc
提出情報
提出日時2022/09/22 07:54:38
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者HyperToy
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量87 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
87 MB