SELECT AVG(温度) FROM TABLE1 GROUP BY DATEPART ( minute , 时间 )

解决方案 »

  1.   

    应该是SELECT DATEPART( hour, 时间 ) 时间,AVG(温度) 温度 FROM TABLE1 GROUP BY DATEPART( hour, 时间 )
      

  2.   

    select convert(varchar(13),时间,120) as 时间,avg( 温度) as 平均值 from tb
    group by convert(varchar(13),时间,120)
      

  3.   

    declare @tb table(时间 datetime, 温度 decimal(6,1))
    insert @tb
    select '2005-3-5 12:10:08' ,  15.0  union all
    select '2005-3-5 12:20:40' ,  14.4  union all
    select '2005-3-5 13:09:09' ,  18.8declare @tb table(时间 datetime, 温度 decimal(6,1))
    insert @tb
    select '2005-3-5 12:10:08' ,  15.0  union all
    select '2005-3-5 12:20:40' ,  14.4  union all
    select '2005-3-5 13:09:09' ,  18.8select 时间=convert(char(13),时间,120)+':00:00',
           平均温度=cast(avg(温度) as decimal(6,1))
    from @tb
    group by convert(char(13),时间,120)+':00:00'
    order by 时间
      

  4.   

    SELECT convert(char(10),时间,120) + ' ' + cast(datediff(hh,convert(char(10),时间,120),时间) as varchar)+':00:00',AVG(温度) 
    FROM TABLE1 
    GROUP BY convert(char(10),时间,120) + ' ' + cast(datediff(hh,convert(char(10),时间,120),时间) as varchar)+':00:00'