sql查询连续三天之内都有记录的人员!!

 

 sql查询连续三天之内都有记录的人员!!

select name from
testB a where
exists
(
   select * from testB b
   where b.InsertTime = DATEADD(D,1,a.InsertTime) and a.name=b.name
)
and
exists
(
   select * from testB b
   where b.InsertTime = DATEADD(D,2,a.InsertTime) and a.name=b.name
)
group by name

你可能感兴趣的:(sql)