出来了一个,但总是感觉不对。贴上来看看,如果不对应该怎么写?我要查询本周登录下周不再登录的用户数量。
select count(distinct playerId) from log_login l1 where week(now())-1=week(loginTime) and exists(select 1 from log_login l2 where l1.playerId = l2.playerId and week(NOW())=week(loginTime));
mysql查询周留存
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答
jinnianshilongnian 2013-05-02 17:14关注select count(distinct playerId) from log_login l1 where week(now())=week(loginTime) and exists(select 1 from log_login l2 where l1.playerId = l2.playerId and week(NOW()) - 1=week(loginTime));
留存率是:上周登录了 这周也登录了 你写的按理说没错
我要查询本周登录下周不再登录的用户数量。 不是下周 而是上周
select count(distinct playerId) from log_login l1 where week(now())-1=week(loginTime) and exists(select 1 from log_login l2 where l1.playerId = l2.playerId and week(NOW())=week(loginTime));本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报