The results of applying the select list to R depend on
whether GROUP BY or HAVING is used:
If GROUP BY or HAVING is used
- Each column-name in the select list
must identify a grouping expression, or be specified within an aggregate
function, or be a correlated reference:
- If the grouping expression is a column name, the select list may
apply additional operators to the column name. For example, if the
grouping expression is column C1, the select list may contain C1+1.
- If the grouping expression is not a column name, the select list
may not apply additional operators to the expression. For example,
if the grouping expression is C1+1, the select list may contain C1+1,
but not (C1+1)/8.
- The select list is applied to each group of R, and the result
contains as many rows as there are groups in R. When the select list
is applied to a group of R, that group is the source of the arguments
of the aggregate functions in the select list.
- The RRN, RID, DATAPARTITIONNAME, DATAPARTITIONNUM, DBPARTITIONNAME,
DBPARTITIONNUM, and HASHED_VALUE functions cannot be specified in
the select list.
If neither GROUP BY nor HAVING is used
- The select list
must not include any aggregate functions, or each column-name must
be specified in an aggregate function or be a correlated reference.
- If the select list does not include aggregate functions, it is
applied to each row of R and the result contains as many rows as there
are rows in R.
- If the select list is a list of aggregate functions, R is the
source of the arguments of the functions and the result of applying
the select list is one row.
In either case the nth column of the result contains
the values specified by applying the nth expression in the
operational form of the select list.