日期:2014-05-18 浏览次数:20421 次
select count(1) from tab a where not exists ( select 1 from tab where 号码=a.号码 and 产生时刻 between a.产生时刻 and dateadd(ss,20,a.产生时刻) )
------解决方案--------------------
create table #t(dt datetime,col int) insert into #t values('2007-2-7 14:31:17',1234) insert into #t values('2007-2-7 14:31:20',1234) insert into #t values('2007-2-7 14:33:12',1544) insert into #t values('2007-2-7 14:41:10',1111) select count(1) from #t a where not exists (select 1 from #t where dt>a.dt and dt<=dateadd(ss,20,a.dt) and col=a.col) ----------- 3 (1 行受影响)