ソースコード
SELECT
    COMBI.ITEM_A
    ,COMBI.ITEM_B
    ,ROUND(CAST(COMBI.PURCHASE_COUNT AS REAL) / (SELECT COUNT(DISTINCT MEMBER_CODE) FROM PURCHASE_HISTORY), 5) * 100 AS SUPPORT
    ,ROUND(CAST(COMBI.PURCHASE_COUNT AS REAL) / ITEM.PURCHASE_COUNT, 5) * 100 AS CONFIDENCE
    ,ROUND(CAST(COMBI.PURCHASE_COUNT AS REAL) / ITEM.PURCHASE_COUNT / ALL_B.PURCHASE_COUNT, 5) * 100 AS LIFT

FROM
    (
    SELECT
        ITEM_CODE
        ,COUNT(DISTINCT MEMBER_CODE) AS PURCHASE_COUNT
    FROM
        PURCHASE_HISTORY
    GROUP BY
        ITEM_CODE
    ) AS ITEM
INNER JOIN
    (
    SELECT
        A.ITEM_CODE AS ITEM_A
        ,B.ITEM_CODE AS ITEM_B
        ,COUNT(DISTINCT A.MEMBER_CODE) AS PURCHASE_COUNT
    FROM
        PURCHASE_HISTORY AS A
    INNER JOIN
        PURCHASE_HISTORY AS B
    ON
        A.MEMBER_CODE = B.MEMBER_CODE
    AND
        A.ITEM_CODE <> B.ITEM_CODE
    GROUP BY
        A.ITEM_CODE
        ,B.ITEM_CODE
    ) AS COMBI
ON
    COMBI.ITEM_A = ITEM.ITEM_CODE
INNER JOIN
    (
    SELECT
        ITEM_CODE
        ,CAST(COUNT(DISTINCT MEMBER_CODE) AS REAL) / (SELECT COUNT(DISTINCT MEMBER_CODE) FROM PURCHASE_HISTORY) AS PURCHASE_COUNT
    FROM
        PURCHASE_HISTORY
    GROUP BY
        ITEM_CODE
    ) AS ALL_B
ON
    COMBI.ITEM_B = ALL_B.ITEM_CODE
提出情報
提出日時2024/04/20 17:56:09
コンテスト第11回 SQLコンテスト
問題アソシエーション分析
受験者miyaza
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
84 MB
データパターン2
WA
84 MB
データパターン3
WA
84 MB