You can use aggregate functions in dynamic queries.
When using the Query.select(String) method, 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.
Query query1 = new Query();
query1.select("MAX(c.id), MIN(c.name) as minName");