delete
    a 
from 
    表 a
where
    id = (select top 1 id from 表 where 编号 = a.编号 and datediff(mi,时间,a.时间)<10 )

解决方案 »

  1.   

    你的条件没有说清楚,你的例子的“编号”都是不同的,你的语句却有 
    ON l.编号=r.编号先说清楚问题吧
      

  2.   

    select id ,编号,时间 
    from table 
    group by 时间 
    into @tmptable declare @tmpcount int 
    declare @count int 
    set @count=1select @tmpcoutn=count(*)
    from table 
    group by 时间while @count<=@tmpcount
    begin delete from table 
    where 时间 <(select top 1 时间+10 as tmptime  from @tmptable )
    end begin 
    end while 
    可将该段代码放在存储过程中执行
      

  3.   

    表述不当,改改
    数据结构:
    id       编号              时间
    19174 008D9D5027  2005-05-04 17:33:00
    19483 008D9D5027  2005-05-04 18:15:00
    19749 008D9D5027  2005-05-04 21:32:00
    20002 008D9D5027  2005-05-05 07:35:00
    20366 008D9D5027  2005-05-05 12:01:00
    20789 008D9D5027  2005-05-05 13:17:00
    20984 008D9D5027  2005-05-05 17:32:00
    21327 008D9D5027  2005-05-05 18:15:00
    21625 008D9D5027  2005-05-05 21:33:00
    21634 FE23839293  2005-05-05 21:33:00
    问题:
        相同编号的记录,如何删除间隔时间小于10分钟的记录,同样时间的只留一条.
        连续的间隔时间小于10分钟的记录,如
      13:43:00 13:47:00 13:52:00 13:58:00 13:63:00
        那么保留13:43:00 13:58:00,以此类推.
      

  4.   

    一个语句应该是不行的用个笨方法select * into #t1 from tablename
    select * into #t2 from tablename where id is nullwhile exists (select * from #t1)
    begin
         insert #t2 select * from #t1 where 时间=(select min(时间) from #t1 where 编号=a.编号)
         delete #t1
         from #t1 t1,#t2 t2
         where t1.编号=t2.编号
         and datediff(mi,t2.时间,t1.时间)<10 
    enddrop table #t1delete tablename
    where id not in (select id from #t2)drop table #t2
    --没有测试