ソースコード
SELECT
    ED.CODE
    ,ED.NAME
    ,ED.CNT
    ,TT.CNT AS TTCNT
    ,ROUND(ED.CNT / TT.CNT, 5) * 100 AS AP
    FROM
    DRINK_HABITS DH
    INNER JOIN
    (
        SELECT
            MAX(PF.PF_CODE) AS CODE 
            ,MAX(PF.PF_NAME) AS NAME 
            ,MAX(SS.CNT) CNT
            FROM
            PREFECTURE PF
            INNER JOIN (
                SELECT
                    PF_CODE
                    ,COUNT(*) AS CNT
                FROM
                    DRINK_HABITS
                WHERE
                    GENDER_CODE <> '1'
                    AND CATEGORY_CODE = '120' 
                GROUP BY
                PF_CODE
                ) SS
            ON SS.PF_CODE = PF.PF_CODE
        WHERE
            1 = 1
        GROUP BY
        PF.PF_CODE
    ) ED
    ON DH.PF_CODE = ED.CODE
    INNER JOIN
    (
        SELECT
            MAX(PF.PF_CODE) AS CODE 
            ,MAX(PF.PF_NAME) AS NAME 
            ,MAX(SS.CNT) CNT
            FROM
            PREFECTURE PF
            INNER JOIN (
                SELECT
                    PF_CODE
                    ,COUNT(*) AS CNT
                FROM
                    DRINK_HABITS
                WHERE
                    GENDER_CODE <> '1'
                GROUP BY
                PF_CODE
                ) SS
            ON SS.PF_CODE = PF.PF_CODE
        WHERE
            1 = 1
        GROUP BY
        PF.PF_CODE
    ) TT
    ON DH.PF_CODE = TT.CODE
    WHERE
    1 = 1
    GROUP BY
    TT.CODE;
提出情報
提出日時2022/09/22 01:33:45
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者yiyiyi
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量94 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
94 MB
データパターン2
WA
91 MB