日期:2014-05-17 浏览次数:20520 次
--#1.每小时平均值
select year(timeid), MONTH(timeid), DAY(timeid), DATEPART(hour, timeid), AVG(v001), AVG(v002), AVG(v003), AVG(v004)
from tb
group by year(timeid), MONTH(timeid), DAY(timeid), DATEPART(hour, timeid)
--#2.每天平均值
select year(timeid), MONTH(timeid), DAY(timeid), AVG(v001), AVG(v002), AVG(v003), AVG(v004)
from tb
group by year(timeid), MONTH(timeid), DAY(timeid)
--#3.每月平均值
select year(timeid), MONTH(timeid), AVG(v001), AVG(v002), AVG(v003), AVG(v004)
from tb
group by year(timeid), MONTH(timeid)
获取两个时间之内的所有日期
--sql 2000
declare @sdate datetime
declare @edate datetime
set @sdate = '2008-10-15 00:00:000'
set @edate = '2009-02-10 00:00:000'
select
dateadd(dd,num,@sdate) dt
from
(select isnull((select count(1) from sysobjects where id<t.id),0) as num from sysobjects t) a
where