ソースコード
with base as (
select
    PF_CODE
    ,SUM(CASE WHEN CATEGORY_CODE=120 THEN AMT ELSE 0 END) as AMT120
    ,SUM(CASE WHEN CATEGORY_CODE=110 THEN AMT ELSE 0 END) as AMT110
from
    DRINK_HABITS
where
    GENDER_CODE in (2,3)
group by
    PF_CODE
)
SELECT
    b.PF_CODE as CODE
    ,PF_NAME as NAME
    ,round(cast(AMT120 as real)/cast(AMT110 as real)*100,1) as PERCENTAGE
from
    base as b
    INNER JOIN
    PREFECTURE as pf
    on b.PF_CODE = pf.PF_CODE
order by
    PERCENTAGE desc
    , b.PF_CODE desc
提出情報
提出日時2024/03/08 11:52:51
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者gP2fWnUzTL
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量83 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
83 MB