Entering content frame

GROUP Clause (group_clause) 

The GROUP clause specifies grouping criteria for a result table (see result table name).

Syntax

<group_clause> ::= GROUP BY <expression>,...

expression

Explanation

Each column name specified in the GROUP clause must identify a result_column_name in the selected columns of the QUERY specification or uniquely identify a column in the tables on which the QUERY specification is based. If necessary, the column name must be qualified with the table identifier.

The GROUP clause allows the functions SUM, AVG, MAX/MIN, COUNT, STDDEV, and VARIANCE to be applied not only to entire result tables but also to groups of rows within a result table. A group is defined by the grouping columns specified in GROUP BY. All rows of a group have the same values in the grouping columns. Rows containing the NULL value in a grouping column are combined to form a group. The same is true for the special NULL value.

GROUP BY generates one row for each group in the result table. The selected columns in the QUERY specification, therefore, may only contain those grouping columns and operations on grouping columns, as well as those expressions that use the functions SUM, AVG, MAX/MIN, COUNT, STDDEV, and VARIANCE.

If no rows satisfy the conditions indicated in the WHERE clause and a group clause was specified, the result table is empty.

Specifying scalable subqueries is not permissible in a GROUP clause.

See also:

Technical Specifications

 

Leaving content frame