KDB 中按组求和
我有一个包含 3 列的 PnL 表。日期、地区、产品。
我正在尝试按地区和产品对所有损益行进行分组。我尝试过的一种方法是按区域和产品求和,如下所示
select PnL : sum(PnL) by Region, Product from table where date inside (d1;d2)
我遇到的问题是意外结果。对于给定的日期范围(d1;d2),我得到了我期望的结果。然而,对于日期范围 (d1;d2+1),我到处都得到 0。
我检查了 d2+1 上的数据可用性,当天数据已经可用。
请注意,服务器是无状态的,并且不可能在变量中使用中间结果。
在 KDB 中实现分组总和的最佳方法是什么?
I have a PnL table with 3 columns. date, region, product.
I'm trying to group all PnL rows by region and product. One way that i've tried is to sum by region and product as following
select PnL : sum(PnL) by region, product from table where date within (d1;d2)
The issue I have is unexpected results. For a given date range (d1;d2) I'm getting the results I'm expecting. However for date range (d1;d2+1) I'm getting 0 everywhere.
I checked the data availability on the d2+1 and data is already available on that day.
Please note that the server is stateless and it is not possible to use intermediate results in variables.
What is the best way to achieve a grouping sum in KDB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论