首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

查询每五分钟收到的message数量

2012-10-06 
查询每5分钟收到的message数量declare @start smalldatetime,@end smalldatetime,@sj smalldatetimecreate

查询每5分钟收到的message数量
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

热点排行