-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql_module_2.txt
More file actions
93 lines (90 loc) · 3.54 KB
/
sql_module_2.txt
File metadata and controls
93 lines (90 loc) · 3.54 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
1.
SELECT
*
FROM
dsv1069.final_assignments_qa
2.
SELECT item_id,
test_a AS test_assignment,
'test_a' AS test_number,
CAST('2020-01-01 00:00:00' AS timestamp) AS dummy_test_start_date
FROM dsv1069.final_assignments_qa
UNION ALL
SELECT item_id,
test_b AS test_assignment,
'test_b' AS test_number,
CAST('2020-01-01 00:00:00' AS timestamp) AS dummy_test_start_date
FROM dsv1069.final_assignments_qa
UNION ALL
SELECT item_id,
test_c AS test_assignment,
'test_c' AS test_number,
CAST('2020-01-01 00:00:00' AS timestamp) AS dummy_test_start_date
FROM dsv1069.final_assignments_qa
UNION ALL
SELECT item_id,
test_d AS test_assignment,
'test_d' AS test_number,
CAST('2020-01-01 00:00:00' AS timestamp) AS dummy_test_start_date
FROM dsv1069.final_assignments_qa
UNION ALL
SELECT item_id,
test_e AS test_assignment,
'test_e' AS test_number,
CAST('2020-01-01 00:00:00' AS timestamp) AS dummy_test_start_date
FROM dsv1069.final_assignments_qa
UNION ALL
SELECT item_id,
test_f AS test_assignment,
'test_f' AS test_number,
CAST('2020-01-01 00:00:00' AS timestamp) AS dummy_test_start_date
FROM dsv1069.final_assignments_qa
3.
SELECT order_binary.test_assignment,
COUNT(DISTINCT order_binary.item_id) AS num_orders,
SUM(order_binary.orders_bin_30d) AS sum_orders_bin_30d
FROM
(SELECT assignments.item_id,
assignments.test_assignment,
MAX(CASE
WHEN (DATE(orders.created_at)-DATE(assignments.test_start_date)) BETWEEN 1 AND 30 THEN 1
ELSE 0
END) AS orders_bin_30d
FROM dsv1069.final_assignments AS assignments
LEFT JOIN dsv1069.orders AS orders
ON assignments.item_id=orders.item_id
WHERE assignments.test_number='item_test_2'
GROUP BY assignments.item_id,
assignments.test_assignment) AS order_binary
GROUP BY order_binary.test_assignment
4.
SELECT view_binary.test_assignment,
COUNT(DISTINCT view_binary.item_id) AS num_views,
SUM(view_binary.view_bin_30d) AS sum_view_bin_30d,
AVG(view_binary.view_bin_30d) AS avg_view_bin_30d
FROM
(SELECT assignments.item_id,
assignments.test_assignment,
MAX(CASE
WHEN (DATE(views.event_time)-DATE(assignments.test_start_date)) BETWEEN 1 AND 30 THEN 1
ELSE 0
END) AS view_bin_30d
FROM dsv1069.final_assignments AS assignments
LEFT JOIN dsv1069.view_item_events AS views
ON assignments.item_id=views.item_id
WHERE assignments.test_number='item_test_2'
GROUP BY assignments.item_id,
assignments.test_assignment
ORDER BY item_id) AS view_binary
GROUP BY view_binary.test_assignment
5.
For orders_bin: lift is -15% – 11% (-2.2%) and pval is 0.74
For views_bin: lift is and pval is -2.1% – 5.9% (1.9%) and pval is 0.36
Therefore for item_test_2, there was no significant difference in either the number of views or the number of orders between control and experiment
6.
View Binary
We can say with 95% confidence that the lift value is 2% and the p_value is 0.2.
There is not a significant difference in the number of views within 30days of the assigned treatment date between the two treatments.
Order binary
There is no detectable change in this metric. The p-value is 0.86
meaning that there is a no significant difference in the number of orders within 30days of the assigned treatment date between the two treatments.