求oracle数据库中表字段的每个小时均值SQL语句

解决方案 »

  1.   

    group by to_char(dt,'hh24')  每小时
    group by trunc(dt,'hh24')  每天每小时
      

  2.   

    表里有时间字段不?select to_char(datecol,'yyyy-mm-dd hh24'),avg(col2)
    from tablename
    group by to_char(datecol,'yyyy-mm-dd hh24')
      

  3.   


    select to_char(dateti,'yyyyMMdd hhmmss') dateCol, datet2 argCol from yyq_date2
    ------------------------------
    dateCol              argCol 
    20100126 010101      50
    20100126 010102      100
    20120101 050117      200select to_char(dateti,'hh'), avg(datet2) from yyq_date2 group by to_char(dateti,'hh') order by to_char(dateti,'hh')
    --------------------------------------
    小时    平均值
    01 75
    05 200