ソースコード
with 
    sum_AMT as (
        select
            PF_CODE
            ,SUM(AMT) as AMT
        from DRINK_HABITS
        where CATEGORY_CODE = '110'
            and GENDER_CODE in ('2','3')
        group by PF_CODE
        )
    ,DRINK_AMT as (
        select
            PF_CODE
            ,SUM(AMT) as AMT
        from 
            DRINK_HABITS
        where 
            CATEGORY_CODE = '120'
            and GENDER_CODE	in ('2','3')
        group by PF_CODE
        )
    ,sub as (
        select
            DRINK_AMT.PF_CODE as PF_CODE
            ,round(cast(DRINK_AMT.AMT as float)*100/sum_AMT.AMT,1) as DR
        from DRINK_AMT
        inner join sum_AMT
            on DRINK_AMT.PF_CODE = sum_AMT.PF_CODE
        group by DRINK_AMT.PF_CODE
        )
select * from sub

select
    sub.PF_CODE as CODE
    ,PERCENTAGE.PF_NAME as NAME
    ,sub.DR as PERCENTAGE
from
    sub
    inner join PREFECTURE
    on sub.PF_CODE = PREFECTURE.PF_CODE
order by
    PERCENTAGE desc
    ,CODE desc
提出情報
提出日時2024/12/03 15:43:12
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者ZZPBAA79
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量85 MB
メッセージ
SQLITE_ERROR: near "select": syntax error
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
85 MB
データパターン2
RE
84 MB