ソースコード
WITH
  ITEM(ITEM_CODE) AS (SELECT DISTINCT ITEM_CODE FROM PURCHASE_HISTORY),
  MEMBER(MC) AS (SELECT DISTINCT MEMBER_CODE FROM PURCHASE_HISTORY),
  MBI(ITEM_CODE, CNT) AS (SELECT ITEM_CODE, COUNT(MEMBER_CODE) FROM PURCHASE_HISTORY GROUP BY ITEM_CODE)
SELECT A.ITEM_CODE AS ITEM_A, B.ITEM_CODE AS ITEM_B,
ROUND(COUNT(A.MEMBER_CODE) * 100.0 / (SELECT COUNT(MC) FROM MEMBER), 5) AS SUPPORT,
ROUND(COUNT(A.MEMBER_CODE) * 100.0 / (SELECT SUM(CNT) FROM MBI WHERE A.ITEM_CODE = MBI.ITEM_CODE), 5) AS CONFIDENCE,
ROUND((COUNT(A.MEMBER_CODE)*1.0 / (SELECT SUM(CNT)*1.0 FROM MBI WHERE A.ITEM_CODE = MBI.ITEM_CODE)) / (1.0 * (SELECT SUM(CNT) FROM MBI WHERE B.ITEM_CODE = MBI.ITEM_CODE) / (SELECT COUNT(MC)*1.0 FROM MEMBER)), 5) AS LIFT
FROM PURCHASE_HISTORY A
JOIN PURCHASE_HISTORY B ON A.MEMBER_CODE = B.MEMBER_CODE AND A.ITEM_CODE <> B.ITEM_CODE
GROUP BY 1,2 ORDER BY 5 DESC, 3 DESC, 4 DESC, 1 DESC;
提出情報
提出日時2024/02/19 09:09:12
コンテスト第11回 SQLコンテスト
問題アソシエーション分析
受験者matsuu
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
83 MB
データパターン2
AC
84 MB
データパターン3
AC
85 MB