ソースコード
SELECT
    DH.PF_CODE CODE
    ,PF.PF_NAME NAME
    ,ROUND(CAST(DL.AMT as REAL) / CAST(TL.AMT as REAL) * 100, 1) AS PERCENTAGE
    FROM
    DRINK_HABITS DH
            INNER JOIN (
                SELECT
                    MAX(PF_CODE) AS PF_CODE
                    ,SUM(AMT) AS AMT
                FROM
                    DRINK_HABITS
                WHERE
                    GENDER_CODE <> '1'
                    AND CATEGORY_CODE = '120'
                GROUP BY
                PF_CODE
                ) DL
    ON DH.PF_CODE = DL.PF_CODE
            INNER JOIN (
                SELECT
                    MAX(PF_CODE)  AS PF_CODE
                    ,SUM(AMT) AS AMT
                FROM
                    DRINK_HABITS
                WHERE
                    GENDER_CODE <> '1'
                    AND CATEGORY_CODE = '110'
                GROUP BY
                PF_CODE
                ) TL
    ON DH.PF_CODE = TL.PF_CODE
    LEFT JOIN PREFECTURE PF
    ON DH.PF_CODE = PF.PF_CODE
    WHERE
    1 = 1
    GROUP BY
    TL.PF_CODE
    ORDER BY
    PERCENTAGE DESC ,  TL.PF_CODE DESC;
提出情報
提出日時2022/09/22 09:10:11
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者yo
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
85 MB
データパターン2
AC
86 MB