题解 | 查询连续登陆的用户
查询连续登陆的用户
https://www.nowcoder.com/practice/9944210610ec417e94140ac09512a3f5
with tab as( select r.user_id,date(l.log_time) as log_time from register_tb as r left join login_tb as l on r.user_id = l.user_id where l.log_time is not null order by r.user_id asc ) select t1.user_id from tab as t1 left join tab as t2 on t1.user_id = t2.user_id and datediff(t2.log_time,t1.log_time)=1 left join tab as t3 on t1.user_id = t3.user_id and datediff(t3.log_time,t1.log_time)=2 where t1.log_time is not null and t2.log_time is not null and t3.log_time is not null order by t1.user_id asc
