Aggregate Functions

You can use aggregate functions in dynamic queries.

When using the select: method from SUPQuery, you can use any of these aggregate functions:

Aggregate Function Supported Datatypes
COUNT integer
MAX string, binary, char, byte, short, int, long, integer, decimal, float, double, date, time, dateTime
MIN string, binary, char, byte, short, int, long, integer, decimal, float, double, date, time, dateTime
SUM byte, short, int, long, integer, decimal, float, double
AVG byte, short, int, long, integer, decimal, float, double

If you use an unsupported type, a PersistenceException is thrown.

SUPQuery *query1 = [SUPQuery getInstance];
[query1 select:@"MAX(c.id), MIN(c.name) as minName"];