ソースコード
with DRINK_HABITS_total as(

    select
        PF_CODE
        ,CATEGORY_CODE
        ,sum(AMT) as total

    from
        DRINK_HABITS
        
    where
        GENDER_CODE in (2,3)
        and CATEGORY_CODE in (110)

    group by
        PF_CODE
        ,CATEGORY_CODE

)

,DRINK_HABITS_drink as(

    select
        PF_CODE
        ,CATEGORY_CODE
        ,sum(AMT) as drink_sum

    from
        DRINK_HABITS
        
    where
        GENDER_CODE in (2,3)
        and CATEGORY_CODE in (120)

    group by
        PF_CODE
        ,CATEGORY_CODE

)


select
    A.PF_CODE as CODE
    ,PR.PF_NAME as NAME
    ,round(cast(B.drink_sum as real)/cast(A.total as real) *100,1) as PERCENTAGE

from
    DRINK_HABITS_total as A

inner join
    DRINK_HABITS_drink as B
    on A.PF_CODE = B.PF_CODE

    ,PREFECTURE as PR
    on A.PF_CODE = PR.PF_CODE

order by
    PERCENTAGE desc
    ,CODE asc

;
提出情報
提出日時2022/09/24 09:16:41
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者jijontaro
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
1/2
状態
メモリ使用量
データパターン1
WA
78 MB
データパターン2
AC
76 MB