Try OpenEdge Now
skip to main content
SQL Reference
SQL Reference : OpenEdge SQL Statements : SELECT : GROUP BY clause : Grouping by column
 
Grouping by column
The result set of a query may be ordered by one or more columns specified in the GROUP BY clause.

Syntax

GROUP BY [table_name.]column_name...

Notes

*For the first column specified in the GROUP BY clause, SQL arranges rows of the result table into groups whose rows all have the same values for the specified column.
*If you specify a second GROUP BY column, SQL groups rows in each main group by values of the second column.
*SQL groups rows for values in additional GROUP BY columns in a similar fashion.
*All columns named in the GROUP BY clause must also be in the select list of the query expression. Conversely, columns in the select list must also be in the GROUP BY clause or be part of an aggregate function.

Example

This example retrieves name and order info for customers with orders:
SELECT DeptCode, LastName
FROM Employee
GROUP BY DeptCode;