ソースコード
select
    p.PF_CODE as CODE
    ,p.PF_NAME as NAME
    ,round(cast(t.SUM_AMT as REAL) / cast(m.SUM_AMT as REAL) * 100, 1) as PERCENTAGE
from 
    (
        select
            dh.PF_CODE as CODE
            ,SUM(dh.AMT) as SUM_AMT
        from
            DRINK_HABITS dh
        where 1=1
            and dh.CATEGORY_CODE = 120
            and dh.GENDER_CODE in (2,3)
        group by
            dh.PF_CODE
    ) as t
    inner join (
        select
            dh.PF_CODE as CODE
            ,SUM(dh.AMT) as SUM_AMT
        from
            DRINK_HABITS dh
        where 1=1
            and dh.CATEGORY_CODE = 110
            and dh.GENDER_CODE in (2,3)
        group by
            dh.PF_CODE
    ) as m on t.CODE = m.CODE
    inner join PREFECTURE p on t.code = p.PF_CODE
order by
    PERCENTAGE desc
    ,CODE desc
;
    
    
提出情報
提出日時2022/09/22 02:20:53
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者KoheiEgami
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量90 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
90 MB