Progress
SQL-89
Guide and Reference
Grouping Data
A group is a set of rows that has the same value for a specified column or columns. The optional GROUP BY clause of a SELECT statement results in a single row in the result table for each group of rows. This clause is useful for arranging a table into conceptual groups so that you can apply an operation or function, such as COUNT or SUM, to each group.
The GROUP BY clause has the following syntax:
The list of columns you specify determines the group. This list consists of a column name or a list of column names separated by commas. The optional HAVING clause excludes particular groups from the query results. The search-condition in the HAVING clause usually involves an aggregate function; a HAVING clause without a GROUP BY clause is valid only if the selection list in the SELECT statement consists of aggregate expressions. See the "Using Aggregate Functions" section for more information. If you specify a HAVING clause without a GROUP BY clause, the entire table is treated as a single group.
The following example displays the total number of items in a product line and the maximum cost of an item in that product line:
NOTE
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |