半小时分组统计个数sql

Posted 上台阶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了半小时分组统计个数sql相关的知识,希望对你有一定的参考价值。

group by 最后一个时间是多少按多少分组

 

select count(1), trunc(a.refund_insert_time, \'hh24\')
+ case when to_char(refund_insert_time,\'mi\') >= \'30\' then numtodsinterval(30,\'minute\') else numtodsinterval(0,\'minute\') end
from refund_record a
where a.refund_complete_time < sysdate - 1
group by trunc(a.refund_insert_time, \'hh24\')
+ case when to_char(refund_insert_time,\'mi\') >= \'30\' then numtodsinterval(30,\'minute\') else numtodsinterval(0,\'minute\') end;

 

 


select count(1), trunc(a.refund_insert_time, \'hh24\')
+ case when to_char(refund_insert_time,\'mi\') >= \'50\' then numtodsinterval(50,\'minute\')
when to_char(refund_insert_time,\'mi\') >= \'30\' then numtodsinterval(30,\'minute\')
else numtodsinterval(0,\'minute\') end
from refund_record a
where a.refund_complete_time < sysdate - 1 and to_char(refund_insert_time,\'yyyy-MM-dd hh24\')=\'2016-07-07 09\'
group by trunc(a.refund_insert_time, \'hh24\')
+ case when to_char(refund_insert_time,\'mi\') >= \'50\' then numtodsinterval(50,\'minute\')
when to_char(refund_insert_time,\'mi\') >= \'30\' then numtodsinterval(30,\'minute\')
else numtodsinterval(0,\'minute\') end;

 

 mysql

 

 

以上是关于半小时分组统计个数sql的主要内容,如果未能解决你的问题,请参考以下文章

oracle怎么按个数分组

问题 B: 分组统计

一条SQL查询多个统计结果

SQL 分组统计,再合并组

SQL按月统计,按日分组

Mysql按周,按月,按日,按小时分组统计数据