对象盒,通过分组另一个属性来总和一个属性
想象一下,我有一个表:
tagid | 数量 |
---|---|
1 | 100 |
1 | 150 |
2 | 200 |
2 | 250 |
,我需要通过对tagid
进行分组来概括金额
。
在SQL中,我们可以通过: 选择tagid,tagid的订单组中的sum(量);
查询结果:
tagid | sum(量) |
---|---|
1 | 250 |
2 | 450 |
我如何在对象盒中获得此类结果?
Imagine I have this table:
tagId | amount |
---|---|
1 | 100 |
1 | 150 |
2 | 200 |
2 | 250 |
And i need to sum the amount
by grouping the tagId
.
In SQL we can do this by:SELECT tagId, SUM(amount) FROM orders GROUP BY tagId;
Query result:
tagId | SUM(amount) |
---|---|
1 | 250 |
2 | 450 |
How can I get such results in ObjectBox ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Object Box中没有组函数。取而代之的是,编写代码以处理您想要的任何方式。有内置的属性查询可以返回可能有用的总和:
源: https:// docs https:// docs .objectbox.io/queries#propertyquery
There is no GROUP function in ObjectBox. Instead, write code to process query results in which ever way you desire. There are built-in property queries that can return a sum that may be helpful:
Source: https://docs.objectbox.io/queries#propertyquery