ソースコード
select * from(
select
    p.PF_CODE as CODE
    ,p.PF_NAME as NAME
    ,ROUND(cast(dh_120.amt as REAL)/cast(dh_110.amt as REAL) * 100,1) as PERCENTAGE
from PREFECTURE p
    left join (
        select
            sum(AMT) as amt
            ,PF_CODE
        from DRINK_HABITS
        where
            CATEGORY_CODE = '110'
            and GENDER_CODE in ('2','3')
        group by
            PF_CODE
    ) dh_110
        on p.PF_CODE = dh_110.PF_CODE
    left join
    (
        select
            sum(AMT) as amt
            ,PF_CODE
        from DRINK_HABITS
        where
            CATEGORY_CODE = '120'
            and GENDER_CODE in ('2','3')
        group by
            PF_CODE
    ) dh_120
        on p.PF_CODE = dh_120.PF_CODE
    where
        dh_110.amt is not null
)
order by
    PERCENTAGE desc
    ,CODE desc
提出情報
提出日時2022/09/21 23:16:58
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者tani.k1
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量82 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
AC
82 MB