ソースコード
SELECT
    PR.PF_CODE as CODE,
    PR.PF_NAME as NAME,
    ROUND((cast(DH3.INSYU as REAL) / cast(DH2.SOUSU as REAL) * 100),1) as PERCENTAGE
FROM
    DRINK_HABITS DH1
LEFT JOIN 
    (
        SELECT
            PF_CODE,
            CATEGORY_CODE,
            SUM(AMT) as SOUSU
        FROM
            DRINK_HABITS
        WHERE
            GENDER_CODE <> '1'
        GROUP BY
            PF_CODE,
            CATEGORY_CODE
    ) DH2
ON 
    DH1.PF_CODE = DH2.PF_CODE
AND DH2.CATEGORY_CODE = '110'
LEFT JOIN 
    (
        SELECT
            PF_CODE,
            CATEGORY_CODE,
            SUM(AMT) as INSYU
        FROM
            DRINK_HABITS
        WHERE
            GENDER_CODE <> '1'
        GROUP BY
            PF_CODE,
            CATEGORY_CODE
    ) DH3
ON 
    DH1.PF_CODE = DH3.PF_CODE
AND DH3.CATEGORY_CODE = '120'
LEFT JOIN
    PREFECTURE PR
ON  
    DH1.PF_CODE = PR.PF_CODE
GROUP BY 
    DH1.PF_CODE
ORDER BY
PERCENTAGE DESC,
DH1.PF_CODE DESC

提出情報
提出日時2022/09/23 01:28:00
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者YusukeYonetani
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量77 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
77 MB
データパターン2
AC
76 MB