BigMemory 4.3.7 | Product Documentation | BigMemory Max Developer Guide | Searching with BigMemory SQL | SQL Syntax and Examples | GROUP BY Clause
 
GROUP BY Clause
The GROUP BY clause provides the option to group results according to specified attributes. Adding a GROUP BY clause to the query both groups the results and allows aggregate functions to be performed on the grouped attributes. The general syntax of the group by clause is:
group by <attribute 1>, <attribute 2>, . . . <attribute n>
The following apply to both the Ehcache Search API's Group By clause and the GROUP BY clause in BigMemory SQL:
*Any attribute specified with the GROUP BY clause should also be included in the target list of the SELECT clause.
*Special KEY or VALUE attributes cannot be used in a GROUP BY clause. This means that KEY, VALUE, or * cannot be used in a query that has a GROUP BY clause.
*Adding a GROUP BY clause to a query changes the semantics of any aggregators passed in, so that they apply only within each group.
*If at least one aggregation function is specified in a query, the grouped attributes are not required to be included in the result set, However, grouped attributes are typically requested to make result processing easier.
GROUP BY Examples
select age from Person where ((age > 100 and zip = 20144) or time > 10) group by age
select age, zip from Person where ((age > 100 and zip = 20144) or time > 10)
group by age, zip