表結構是:USER_ID,日期(我使用時間戳工作)MySQL的每日計數新用戶VS返回的用戶(隊列分析)
例如
user id | Date (TS)
A | '2014-08-10 14:02:53'
A | '2014-08-12 14:03:25'
A | '2014-08-13 14:04:47'
B | '2014-08-13 04:04:47'
...
併爲下一個本週我有
user id | Date (TS)
A | '2014-08-17 09:02:53'
B | '2014-08-17 10:04:47'
B | '2014-08-18 10:04:47'
A | '2014-08-19 10:04:22'
C | '2014-08-19 11:04:47'
...
,併爲今天,我有
user id | Date (TS)
A | '2015-05-27 09:02:53'
B | '2015-05-27 10:04:47'
C | '2015-05-27 10:04:22'
D | '2015-05-27 17:04:47'
我需要知道如何執行單個查詢來查找從其活動一開始就是「返回」用戶的用戶數量。
預期結果:
date | New user | returned User
2014-08-10 | 1 | 0
2014-08-11 | 0 | 0
2014-08-12 | 0 | 1 (A was active on 08/11)
2014-08-13 | 1 | 1 (A was active on 08/12 & 08/11)
...
2014-08-17 | 0 | 2 (A & B were already active)
2014-08-18 | 0 | 1
2014-08-19 | 1 | 1
...
2015-05-27 | 1 | 3 (D is a new user)
#2一些長期搜索後,我發現這裏https://meta.stackoverflow.com/users/107744/spencer7593提供的一些材料:Weekly Active Users for each day from log但我並沒有繼承他的查詢更改輸出我的預期結果。
感謝您的幫助