比如说有一个begintime字段
下面有10条数据  如何把他像用SUM函数一样把它们累积起来

解决方案 »

  1.   

    你要和其他时间做基准计算出来吧
    计算出来后
    同样可以用sum()求和
      

  2.   

    declare @dt datetime
    set @dt=cast('' as datetime)
    select @dt=@dt+begintime from 表這樣?
      

  3.   


    if object_id('tb','u') is not null
       drop table tb
    go
    create table tb
    (
     begintime datetime
    )
    go
    insert into tb
    select '2011-11-11' union all
    select '2011-11-12' union all
    select '2011-11-13'
    go
    select stuff((select ','+cast(begintime as varchar) from tb for xml path('')),1,1,'')
    /*
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    11 11 2011 12:00AM,11 12 2011 12:00AM,11 13 2011 12:00AM(1 行受影响)*/
      

  4.   

    DECLARE @t TABLE(begintime NVARCHAR(10))
    INSERT @t SELECT '01:00'
    INSERT @t SELECT '03:00'
    DECLARE @dt DATETIME
    SET @dt=''
    SELECT @dt=@dt+begintime FROM @tSELECT @dt--同默認日期換算
    /*
    1900-01-01 04:00:00.000*/