PL SQL:每个时间戳的函数
我有一个 16 列表,而第一列是时间戳(即 16/02/2011 00:00:00),并且该表填充有 5 分钟测量值,这意味着每列和日期将有 288 个 5 分钟测量值。如果我想计算,比如说,每天和每月大于 >100 毫秒的“RTTD”列的值,解决方案是什么?
I have a 16 colymns table whereas the first column is the timestamp (i.e. 16/02/2011 00:00:00) and the table is populated with 5min measurements meaning that there will be 288 5min measurements per column and date. If i want to count, lets say, the values of column "RTTD" that are greater than >100 ms every day and every month, what is the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我创建了一个简单的表(我没有关心所有十六列):
这个破烂的匿名块生成四个站四天的读数:
因此这个查询将总结四天内四个站的读数。
COUNT()
忽略 NULL 值,并且 SELECT 利用这一点:对于任何小于 100 的 RTTD 值,CASE()
返回 null。为了按月汇总,您可以只需将
TRUNC(ts)
替换为TRUNC(ts, 'MM')
,其工作原理如下:I have created a simple table ( I haven't bothered with all sixteen columns):
This shonky anonymous block generates four days of readings for four stations:
So this query will summarise the readings for the four stations across the four days.
COUNT()
ignores NULL values, and the SELECT leverages this: theCASE()
returns null for any value of RTTD less than 100.In order to aggregate this by month you simply need to replace
TRUNC(ts)
withTRUNC(ts, 'MM')
, which works like this:不确定你到底想要什么。问题定义太模糊了,我不确定你所说的那个表究竟是怎样的......
无论如何,我想它会是这样的:
Not sure of what exactly you want. The problem definition is too vague, and I am not sure how exactly is that table you're talking about...
Anyway, I guess it would be something like that: