题解 | 查询连续登陆的用户
查询连续登陆的用户
https://www.nowcoder.com/practice/9944210610ec417e94140ac09512a3f5
select distinct s1.user_id from login_tb s1 left join login_tb s2 on s1.user_id = s2.user_id and datediff(s2.log_time,s1.log_time) = 1 left join login_tb s3 on s1.user_id = s3.user_id and datediff(s3.log_time,s2.log_time) = 1 where s2.user_id is not null and s3.user_id is not null and exists ( select * from register_tb s4 where s4.user_id = s1.user_id ) order by 1