Consider the mysql table,
user_event| created_at
1 2021-12-03
2 2021-12-03
3 2021-12-03
3 2021-12-01
1 2021-11-28
2 2021-11-10
2 2021-11-01
1 2021-11-01
I am trying to find count of users grouped by created_at & count of repeat users if they had an event in the last 10 days
The expected result would be:
created_at | total_users | repeat_users
2021-12-03 3 2
2021-12-02 0 0
2021-12-01 1 0
.
.
2021-11-28 1 0
.
.
2021-11-10 1 1
2021-11-01 2 0
Basically, user_event 1,2,3 had activities on 2021-12-03, so total_users are 3. 2 of them had activity in the last 10 days so, repeat_users should be 2. Similarly, user_event 3 was present on 2021-12-01 but he has no activity in last 10 days, hence repeat_users would be 0 and so on.