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

查询连续登陆的用户

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
全部评论

相关推荐

迷茫的大四🐶:💐孝子启动失败,改为启动咏鹅
点赞 评论 收藏
分享
09-22 22:22
中山大学 Java
双尔:赌对了,不用经历秋招的炼狱真的太好了,羡慕了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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