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 ?
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