ソースコード
SELECT
    ED.CODE
    ,ED.NAME
    ,ROUND(CAST(ED.CNT as REAL) / CAST(TT.CNT as REAL) * 100, 2) AS PERCENTAGE
    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:52:35
コンテスト第2回 SQLコンテスト
問題飲酒率
受験者it
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量94 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
82 MB
データパターン2
WA
94 MB