我正在尝试检索特定A/B测试组合每天的访问次数和转化次数.每种组合代表A/B测试的不同变化.在这里,我只使用'1'
并'2'
代表变化,但从技术上讲,可能会有更多的变化.
我写了以下2个查询,它们独立工作.是否可以组合这些或写一个检索我想要的数据的查询?
访问查询:
SELECT DATE(visit.created), visit.combination, COUNT(visit.id) FROM visit WHERE visit.user_id = 6 AND visit.experiment_id = 1 GROUP BY DATE(visit.created), visit.combination
访问结果:
转化查询:
SELECT DATE(conversion.created), conversion.combination, COUNT(conversion.id) FROM conversion WHERE conversion.user_id = 6 AND conversion.experiment_id = 1 AND conversion.goal_id = 1 GROUP BY DATE(conversion.created), conversion.combination
转化结果:
如果我可以检索一个正在运行的总计(累计)计数,如下所示,请查看最后两列.我已经按照组合对下表进行了分组,因此累积计数更容易理解:
+---------------+-------------+----------------------+-----------------+--------------+--------------+ | DATE(created) | combination | COUNT(conversion.id) | COUNT(visit.id) | cumulative_c | cumulative_v | +---------------+-------------+----------------------+-----------------+--------------+--------------+ | 2015-11-17 | 1 | 1 | 3 | 1 | 3 | | 2015-11-18 | 1 | 7 | 4 | 8 | 7 | | 2015-11-19 | 1 | 3 | 8 | 11 | 15 | | 2015-11-17 | 2 | 4 | 1 | 4 | 1 | | 2015-11-18 | 2 | 2 | 6 | 6 | 7 | | 2015-11-19 | 2 | 9 | 6 | 15 | 13 | +---------------+-------------+----------------------+-----------------+--------------+--------------+
数据库架构: