oracle sql如何查询一段时间内 每隔五分钟的数据量

表 CIM_CUSTOMER_ORDER, "ID_" VARCHAR2(32),"ACCEPT_TIME" VARCHAR2(24)

insert into CIM_CUSTOMER_ORDER values ('1','2017-02-17 10:03:33')
insert into CIM_CUSTOMER_ORDER values ('2','2017-02-17 10:13:33')
insert into CIM_CUSTOMER_ORDER values ('3','2017-02-17 10:23:33')
insert into CIM_CUSTOMER_ORDER values ('4','2017-02-17 10:33:33')
insert into CIM_CUSTOMER_ORDER values ('5','2017-02-17 10:43:33')

想统计出 2017-02-17 10:00:00到2017-02-17 10:45:33这段时间内,每隔五分钟的数据量
结果如:
2017-02-17 10:05:00 1
2017-02-17 10:10:00 1
2017-02-17 10:15:00 2
2017-02-17 10:20:00 2
2017-02-17 10:25:00 3
2017-02-17 10:30:00 3
2017-02-17 10:35:00 4
..........

1个回答

select ACCEPT_TIME,count(*)
from (
select ID_, substr(d,1,15)||(case when to_number(substr(d,16,1))<5 then '0' else '5' end)||':00' as ACCEPT_TIME
from CIM_CUSTOMER_ORDER
)group by ACCEPT_TIME

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐