-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssociation Rule Analysis SQL.sql
47 lines (42 loc) · 1 KB
/
Association Rule Analysis SQL.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
CREATE database project1;
SELECT *
FROM project1.resultba2;
SELECT itemA,
itemB,
supportAB,
confidenceAtoB
FROM project1.resultba2
WHERE supportAB > 0.02
AND confidenceAtoB > 0.2
ORDER BY confidenceAtoB DESC;
SELECT itemA,
itemB,
supportAB,
confidenceAtoB
FROM project1.resultba2
WHERE supportAB > 0
AND confidenceAtoB > 0
AND itemA = "Coconut Chia Bar"
ORDER BY confidenceAtoB DESC;
CREATE VIEW CartItems1(itemA,
itemB,
supportAB,
confidenceAtoB) AS
SELECT itemA,
itemB,
supportAB,
confidenceAtoB
FROM project1.resultba2
WHERE supportAB > 0
AND confidenceAtoB > 0
AND itemA = "Coconut Chia Bar"
OR itemA = "Chocolate Sea Salt"
OR itemA = "Peanut Butter Bar"
ORDER BY confidenceAtoB DESC;
SELECT *
FROM CartItems1
WHERE itemB != "Coconut Chia Bar"
AND itemB != "Chocolate Sea Salt"
AND itemB != "Chocolate Peanut Butter"
ORDER BY confidenceAtoB DESC
LIMIT 3;