GROUP BY
Combines rows that have the same values into summary rows.
Example: Group number of workers by location.
Syntax
GROUP BY field1, field2, ...fieldN
Arguments
Argument | Description |
|---|---|
field1 , field2 , ...fieldN
| The aliases for the fields by which you want to group results. |
Example
Return the location and the maximum years of service for a worker at that location from the
allWorkers
data source:SELECT location, max(yearsOfService) FROM allWorkers GROUP BY location
Limitations
You can't group by:
- Aggregated fields. Examples:SUM(field1),AVG(field1).
- Currency fields.
- Multi-instance fields.