orcale 根据时间段统计(分钟,小时,天,月,年)

来源:互联网 发布:手机淘宝查号截图图片 编辑:程序博客网 时间:2024/05/29 09:01
 

select 类别, trunc(时间, 'mi'),
       sum(字段),
       avg(字段),
       max(字段),
       min(字段),
       from table1
       where 类别 = 'value'
 group by 类别, trunc(下单时间, 'mi')
 

改变  'mi'  按如下说明即可;

小时: hh24; 天: dd; 月:mm; 年: yy;

  select t.log_type,
         trunc(t.collect_time, 'mi'),
         sum(t.succ_req_num),
         avg(t.succ_req_num),
         max(t.succ_req_num),
         min(t.succ_req_num),
         count(1)
          from tb_server_log t where t.log_type = '0'
         group by t.log_type, trunc(t.collect_time, 'mi') ;