首页 新闻 会员 周边

sql查询语句查询每10分钟的数据

0
悬赏园豆:50 [已解决问题] 解决于 2019-08-27 11:01

我想请问:
一般sql查询语句可以查看每分钟成功率,每小时的成功率,每天都可以查询。
to_char,trunc 都是按照系统设定的‘YYMMDDHHMISS’
如果想查询在莫一天,按照10分钟查询,(好比 6.以后 到现在9. 期间每10分钟的成功率 )
各位大佬有什么好办法。
感谢。

邪祺Gods的主页 邪祺Gods | 初学一级 | 园豆:154
提问于:2019-08-26 09:38
< >
分享
最佳答案
1

新建一个统计表。每隔10分钟查询一遍数据,把统计结果插入到统计表。然后你查询统计结果时就查询这个统计表就好了。

收获园豆:50
会长 | 专家六级 |园豆:12401 | 2019-08-27 09:41

大神有简单的demo嘛

邪祺Gods | 园豆:154 (初学一级) | 2019-08-27 09:43

@邪祺Gods: 没有。你查“开源调度器”,用调度器来控制执行统计的时间(有的数据库本身也支持定时操作)。另外,我不是大神,我是狗

会长 | 园豆:12401 (专家六级) | 2019-08-27 10:57

@会长: 谢谢您。只是突然想到这个问题 我去查查。

邪祺Gods | 园豆:154 (初学一级) | 2019-08-27 11:00
其他回答(2)
1

創建一個排程即可。

獨木成林 | 园豆:202 (菜鸟二级) | 2019-08-26 10:30

有简单的例子嘛 谢谢老板。

支持(0) 反对(0) 邪祺Gods | 园豆:154 (初学一级) | 2019-08-27 09:44
0

Oracle数据库有一个比较常用的SQL,用来计算每个小时的归档日志量,与楼主所表的的类似:

SELECT trunc(first_time) "Date",
to_char(first_time, 'Dy') "Day",
count(1) "Total",
SUM(decode(to_char(first_time, 'hh24'),'00',1,0)) "h0",
SUM(decode(to_char(first_time, 'hh24'),'01',1,0)) "h1",
SUM(decode(to_char(first_time, 'hh24'),'02',1,0)) "h2",
SUM(decode(to_char(first_time, 'hh24'),'03',1,0)) "h3",
SUM(decode(to_char(first_time, 'hh24'),'04',1,0)) "h4",
SUM(decode(to_char(first_time, 'hh24'),'05',1,0)) "h5",
SUM(decode(to_char(first_time, 'hh24'),'06',1,0)) "h6",
SUM(decode(to_char(first_time, 'hh24'),'07',1,0)) "h7",
SUM(decode(to_char(first_time, 'hh24'),'08',1,0)) "h8",
SUM(decode(to_char(first_time, 'hh24'),'09',1,0)) "h9",
SUM(decode(to_char(first_time, 'hh24'),'10',1,0)) "h10",
SUM(decode(to_char(first_time, 'hh24'),'11',1,0)) "h11",
SUM(decode(to_char(first_time, 'hh24'),'12',1,0)) "h12",
SUM(decode(to_char(first_time, 'hh24'),'13',1,0)) "h13",
SUM(decode(to_char(first_time, 'hh24'),'14',1,0)) "h14",
SUM(decode(to_char(first_time, 'hh24'),'15',1,0)) "h15",
SUM(decode(to_char(first_time, 'hh24'),'16',1,0)) "h16",
SUM(decode(to_char(first_time, 'hh24'),'17',1,0)) "h17",
SUM(decode(to_char(first_time, 'hh24'),'18',1,0)) "h18",
SUM(decode(to_char(first_time, 'hh24'),'19',1,0)) "h19",
SUM(decode(to_char(first_time, 'hh24'),'20',1,0)) "h20",
SUM(decode(to_char(first_time, 'hh24'),'21',1,0)) "h21",
SUM(decode(to_char(first_time, 'hh24'),'22',1,0)) "h22",
SUM(decode(to_char(first_time, 'hh24'),'23',1,0)) "h23"
FROM V$log_history
where trunc(first_time)>sysdate-30
group by trunc(first_time), to_char(first_time, 'Dy')
Order by 1;

gegeman | 园豆:55 (初学一级) | 2020-01-21 22:50
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册