34,837
社区成员




select
a.*
from
(select id=row_number()over(order by getdate()),* from tb) a,
(select id=row_number()over(order by getdate()),* from tb) b
where
a.id=b.id-1
and
datediff(ss,a.time,b.time)<=2
??
SELECT * FROM @a a WHERE
datediff(ss,date,(SELECT min(date) FROM @a WHERE date>a.date))<=2
OR
datediff(ss,(SELECT max(date) FROM @a WHERE date<a.date),date)<=2
select
a.*
from
tb a,tb b
where
a.id=b.id-1
and
datediff(ss,a.time,b.time)<=2