I've searched a lot but can't find any documantation or an example for GROUP BY queries.
For now, even putting RLMResults in a loop can solve my problem but is there an elegant way to get?
It was discussed at the Java group and also applies for the iOS implementation.
Nov 2014
GROUP BY is only interesting in combination with some kind of aggregate function. We have the most common ones directly on RealmResults, like sum(), average(), max() and min(), are these what you are looking for or do you have something else in mind?
We actually implemented DISTINCT but found some bugs that needed to be fixed before it can be released. So hopefully really soon :)
The distinct operation is yet not available but there is an easy workaround for it.
Oct 2015
DISTINCT made progress in core, but isn't yet fully implemented and wasn't so exposed yet neither in the Java binding nor in any other. We're working on that and will make sure to report back here once we have something to test out.
Regarding examples, the official docs have one:
The aggregate expressions @count, @min, @max, @sum and @avg are supported on RLMArray properties, e.g.
[Company objectsWhere:@"employees.@count > 5"]
to find all companies with more than five employees.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With