不知道用datediff 函数可不可以实现

解决方案 »

  1.   

    用 GROUP BY但是不知道是根据那条来往后推迟一分钟啊 
      

  2.   

    declare @t table(编号 varchar(10), 姓名 varchar(10),日期 smalldatetime,时间 datetime)
    insert @t select
    '1001','张三','2008-04-15','08:05:00' union select
    '1001','张三','2008-04-15','08:05:30' union select 
    '1001','张三','2005-04-15','08:06:00'
    select * 
    from @t a
    where datediff(s,(select top 1 时间 from @t where 时间 <= a.时间 order by 时间 asc),时间) < 60
    order by 时间 /*
    编号         姓名         日期                                                     时间                                                     
    ---------- ---------- ------------------------------------------------------ ------------------------------------------------------ 
    1001       张三         2008-04-15 00:00:00                                    1900-01-01 08:05:00.000
    1001       张三         2008-04-15 00:00:00                                    1900-01-01 08:05:30.000(所影响的行数为 2 行)
    */
      

  3.   

    楼主是不是想这样:select 编号, 姓名, 日期, datepart(hh,时间), datepart(mi,时间), count(*)
    from #table
    group by 编号, 姓名, 日期, datepart(hh,时间), datepart(mi,时间)