PLSQL-群函数的参数化定义
我有一个表,我想在其中应用一些聚合函数,以特定列的特定元素的分组为标准。假设下面的例子:
TIMESTAMP SITE VALUE
10:00 A 100
10:00 B 50
10:00 C 25
10:00 D 25
10:05 A 25
10:05 B 15
10:05 C 5
10:05 D 10
我想找到按 SITE
、TIMESTAMP
分组的平均值,但站点 A、B 我希望将其估计为 1,这意味着我想要用 A 替换 B
然后求平均值:
TIMESTAMP SITE VALUE
10:00 A 75
10:00 A 75
10:00 C 25
10:00 D 25
10:05 A 20
10:05 A 20
10:05 C 5
10:05 D 10
一种方法是更新表设置 B=A
,但如果我想要的话,这不是一个复杂的解决方案未来可对更多SITES
进行分组
I have a table where i want to apply some aggregation functions having as criteria the grouping of spesific element of specific column. Assume the example below:
TIMESTAMP SITE VALUE
10:00 A 100
10:00 B 50
10:00 C 25
10:00 D 25
10:05 A 25
10:05 B 15
10:05 C 5
10:05 D 10
i want to find the average value grouping by SITE
, TIMESTAMP
but the site A,B i want it to be estimated as one, meaning that i wanted to REPLACE B WITH A
have AND THEN find the average:
TIMESTAMP SITE VALUE
10:00 A 75
10:00 A 75
10:00 C 25
10:00 D 25
10:05 A 20
10:05 A 20
10:05 C 5
10:05 D 10
One way is to update the table setting B=A
, but this is not such a sophisticated solution if i want in future to group more SITES
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要更新表。
You don't need to update the table.
您可以分别找到未组合和组合站点的平均值,然后将它们合并在一起,就像这样 -
只是一个想法,未测试 SQL
You can find the averages of uncombined and combined sites separately and then union them togeather, like this -
Just an idea, not tested the sql