ソースコード
select
    DH1.PF_CODE AS CODE
    ,PF.PF_NAME AS NAME
    ,ROUND(
            CAST(SUM(DH2.AMT) AS REAL) / 
            CAST(SUM(DH1.AMT) AS REAL) * 100
            , 1) AS PERCENTAGE
FROM DRINK_HABITS AS DH1
    INNER JOIN DRINK_HABITS AS DH2
        ON DH2.PF_CODE = DH1.PF_CODE
        AND DH2.CATEGORY_CODE = DH1.CATEGORY_CODE
        AND DH2.GENDER_CODE = DH1.GENDER_CODE
        AND DH2.GENDER_CODE <> '0'
        AND DH2.CATEGORY_CODE = '120'
    INNER JOIN PREFECTURE AS PF
        ON DH1.PF_CODE = PF.PF_CODE
        AND DH2.PF_CODE = PF.PF_CODE
WHERE DH1.GENDER_CODE <> '0'
GROUP BY DH1.PF_CODE
ORDER BY
    PERCENTAGE DESC
    DH1.PF_CODE DESC
;
提出情報
提出日時2022/09/22 11:58:15
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者pein1192
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量97 MB
メッセージ
SQLITE_ERROR: near "DH1": syntax error
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
96 MB
データパターン2
RE
97 MB