Reputation: 8580
Can i run complex SQL queries on realm? if not how does it claim to be a replacement for SQLite?
In particular im looking for a way to sum diffrence between two colmuns in my table how is it done?
Note that im looking for an api call rather then findAll() and a loop...
Upvotes: 1
Views: 503
Reputation: 6571
Sorry if i misunderstand your question, but I think this might be what your asking for. The sum function will calculate the sum of all numbers in a column and then you just subtract to get the difference.
int i = realm.where(RealmObject.class).sum("num2")-realm.where(RealmObject.class).sum("num1");
Upvotes: 1