呵呵,间隔可定时5分钟么?现在能想到两种解法,
等等,看半天原来这么简单。。所谓15分钟为间隔的意思是整点分成15分钟吧?一点技术含量也没有declare @Div smallint
select @Div=15
select max(strTime),sum(intValue)
from #t
gaoup by datediff(minute,StrTime,'00:00')/@Div
等等,看半天原来这么简单。。所谓15分钟为间隔的意思是整点分成15分钟吧?一点技术含量也没有declare @Div smallint
select @Div=15
select max(strTime),sum(intValue)
from #t
gaoup by datediff(minute,StrTime,'00:00')/@Div
select @begintime=cast('2005-02-22 '+min(strtime)+':00' as smalldatetime) from [table]
set @i=4
select sn=identity(int,0,1) into #t from [table]
select substring(convert(varchar,b.comparetime,120),10,4) as strtime,
intvalue=
(select sum(intvalue) from
[table] a where dateadd(min,sn*5,@begintime)<=b.comparetime),
from (select dateadd(min,sn*5*@i,@begintime) as comparetime,sn from #t) b
intvalue=(select sum(intvalue) from [table]
where sn<=a.sn) from [table] a where (sn)%4=0