题解 | 查询连续登陆的用户

查询连续登陆的用户

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

全部评论

相关推荐

鱼专:别投了,我看到有人点了第二个链接投递,还没退出界面,不合适的邮件就发过来了
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
03-19 10:38
实力求职者:真的绷不住了,第一张霸总人设,第二张求生欲拉满
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务