declare @start smalldatetime,@end smalldatetime,@sj smalldatetime
create table #tmp(tm smalldatetime,cnt int)
set @start='2012-01-08 00:00:00'
set @end='2012-01-09 00:00:00'
set @sj=dateadd(mi,5,@start)
while @sj<=@end
begin
insert into #tmp(tm,cnt)
select @sj,count(*) from NotificationHistory
where
(LastUpdate between @start and @sj )
and DataGroup = 'Price'
set @start=@sj
set @sj=dateadd(mi,5,@start)
--select @start,@sj
end
select tm,cnt from #tmp order by tm
drop table #tmp
create table #tmp(tm smalldatetime,cnt int)
set @start='2012-01-08 00:00:00'
set @end='2012-01-09 00:00:00'
set @sj=dateadd(mi,5,@start)
while @sj<=@end
begin
insert into #tmp(tm,cnt)
select @sj,count(*) from NotificationHistory
where
(LastUpdate between @start and @sj )
and DataGroup = 'Price'
set @start=@sj
set @sj=dateadd(mi,5,@start)
--select @start,@sj
end
select tm,cnt from #tmp order by tm
drop table #tmp