ソースコード
with
total_people as(
select
    PF_CODE, AMT
from
    DRINK_HABITS
where
    CATEGORY_CODE = 110
    GENDER_CODE != 1
group by
    PF_CODE
)

, drink_everyday as(
select
    PF_CODE, AMT
from
    DRINK_HABITS
where
    CATEGORY_CODE = 120
    GENDER_CODE != 1
group by
    PF_CODE
)
select
    pf.PF_CODE as CODE
    , PF_NAME as NAME
    , round(cast(de.AMT as real) / cast(tp.AMT as real) * 100, 2) as PERCENTAGE
from
    PREFECTURE as pf
    join total_people as tp
    on pf.PF_CODE = tp.PF_CODE
    join drink_everyday as de
    on pf.PF_CODE = de.PF_CODE
order by
    PERCENTAGE desc, CODE desc
提出情報
提出日時2022/12/28 14:51:06
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者2takumax
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量79 MB
メッセージ
SQLITE_ERROR: near "GENDER_CODE": syntax error
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
78 MB
データパターン2
RE
79 MB