mysql查询周流失

select count(1) from (select distinct playerId from log_login l1 where week(now())-1=week(loginTime) and not exists(select distinct playerId from log_login l2 where l1.playerId = l2.playerId and week(NOW()) =week(loginTime)))t;

select count(distinct playerId) from log_login l1 where week(now())-1=week(loginTime) and level=1 and not exists(select distinct playerId from log_login l2 where l1.playerId = l2.playerId and week(NOW()) =week(loginTime) and level=1);

2个回答

select count(distinct playerId) from log_login l1 where week(now())=week(loginTime) and level=1 and not exists(select distinct playerId from log_login l2 where l1.playerId = l2.playerId and week(NOW()) -1=week(loginTime));

7 年多之前 回复
jinnianshilongnian 只查自己的 你那样写 是查全表最高的
7 年多之前 回复

7 年多之前 回复
jinnianshilongnian (select max(level) from log_login l3 where l1.playerId = l3.playerId )
7 年多之前 回复

7 年多之前 回复
jinnianshilongnian l1.playerId = l2.playerId 这么连表 你写出来试下 然后我帮你分析下
7 年多之前 回复

7 年多之前 回复
jinnianshilongnian select max(level) from log_login 这里边要加和l1 相等的条件
7 年多之前 回复

7 年多之前 回复
jinnianshilongnian (select max(level) from ) = 1 那再写个子查询 判断 试试
7 年多之前 回复

7 年多之前 回复

7 年多之前 回复