--按六小时分组
select trunc(to_number(to_char(created_time, 'hh24')) / 6),count(*)
from t_test
where created_time > trunc(sysdate - 40)
group by trunc(to_number(to_char(created_time, 'hh24')) / 6)
--按12小时分组
select trunc(to_number(to_char(created_time, 'hh24')) / 6),count(*)
from t_test
where created_time > trunc(sysdate - 40)
group by trunc(to_number(to_char(created_time, 'hh24')) / 6)
复制代码
本文介绍了一种使用SQL对特定时间段内的数据进行不同粒度(如6小时和12小时)的时间分组统计的方法。

1570

被折叠的 条评论
为什么被折叠?



