select substr(time,1,2) time,sum(fee) form tab group by substr(time,1,2)

解决方案 »

  1.   

    select substr(time,1,2) time,sum(fee) 
    from table_name 
    group by substr(time,1,2)
      

  2.   

    select t.time,sum(t.fee) from (select substr(time,1,2) time,fee from table) t group by t.time;
      

  3.   

    select substr(to_char(time,'hhmmss'),1,2) time,sum(fee) fee from tablename group by substr(to_char(time,'hhmmss'),1,2)
      

  4.   

    select to_char(time,'hh') time,sum(fee) from tablename group by to_char(time,'hh')
    看你的time是什么类型的,是字符型的话,就用楼上兄弟们的办法
      

  5.   

    要根据你的时间存储格式加一个 group by 语句:
    如果是字符型的,可以按照一楼的方法。
    如果是时间型的,可以按照 ORARichard(没钱的日子好难过啊) 方法:
    group by to_char(time,'HH24')