连续登录 假设我们的字段有 id 和 登录日期 dt 我们以连续登录3天为例 select id,diffdt from ( select id, sortdt - dt as diffdt from (select id, dt, rownumber() over(partition by id order by dt) as sortdt from employee )t1 )t2 group by id,diffdt having count(*) = 3;