我正在写一份请求,要求按日同类群组建立第7天的保留时间图表。我有像这样的数据集:
user_id, event_name, datetime 1, install, 20 jan 2018 10:00:00 1, activity, 20 jan 2018 11:00:00 2, install, 20 feb 2018 12:00:00 2, activity, 22 feb 2018 13:00:00
我在phpmyadmin中建立了两个表,在其中按日期时间对user_id进行了分组,并在其中先将event_name ='activate'并在其后将条件'install'分组。尝试将COUNT(user_id)与第三张表中的这2张表分开后。
(第一个表-result_install):
INSERT INTO result_install SELECT COUNT(user_id), datetime FROM customers WHERE event_name = 'install' GROUP BY datetime ORDER BY datetime;
(第二张表-result_activate):
INSERT INTO result_activate SELECT COUNT(user_id), datetime FROM customers WHERE event_name = 'activate' and datetime = '2018-01-26';
(第三张表-结果):
INSERT INTO result(retention_rate, date_retention) SELECT result_activate.count_activate / result_install.count_install AS retention_rate, date_install FROM result_install;
我希望输出的保持率像11/25