•
A union between embedded INSERT expressions is not supported.
•
Declaring a cursor on an embedded INSERT statement is not supported.
DISTINCT Aggregate Functions
An aggregate function can accept an argument specified as DISTINCT, which eliminates duplicate
values before the aggregate function is applied. For a given grouping, multiple DISTINCT
aggregates are allowed and can be used with non distinct aggregates. There is a restriction that
DISTINCT STDDEV and VARIANCE cannot be used with multiple DISTINCT aggregates.
Limitations of DISTINCT Aggregates
•
There is no limit to the number of distinct aggregates.
•
Distinct STDDEV and distinct VARIANCE are not supported with multiple distinct
aggregates. For example, this statement will result in an error.
SELECT sum(distinct a), stddev(distinct b) from T group by d;
Examples of Multiple Distinct Aggregates
•
This statement contains distinct aggregates:
SELECT sum(distinct a), count(distinct b), avg(distinct c)
from T group by d;
•
This statement does not contain multiple distincts. Since each distinct aggregate is on the
same column (a), this is treated as one distinct value.
SELECT sum(distinct a), count(distinct a), avg(distinct a)
from T group by d;
•
This statement shows that multiple distinct aggregates can be used with non distinct
aggregates:
SELECT sum(distinct a), avg(distinct b), sum(c)
from T group by d;
Considerations for Select List
•
The * and corr.* forms of a select-list specification are convenient. However, such
specifications make the order of columns in the SELECT result table dependent on the order
of columns in the current definition of the referenced tables or views.
•
A col-expr is a single column name or a derived column. A derived column is an SQL
value expression; its operands can be numeric, string, datetime, or interval literals, columns,
functions (including aggregate functions) defined on columns, scalar subqueries, CASE
expressions, or CAST expressions. Any single columns named in col-expr must be from
tables or views specified in the FROM clause. For a list of aggregate functions, see
(Set) Functions" (page
•
If col-expr is a single column name, that column of the SELECT result table is a named
column. All other columns are unnamed columns in the result table (and have the (EXPR)
heading) unless you use the AS clause to specify a name for a derived column.
Considerations for SEQUENCE BY
If you include both SEQUENCE BY and GROUP BY clauses in the same SELECT statement, the
values of the sequence functions must be computed first and then become input for the aggregate
functions in the statement. For more information, see
Considerations for GROUP BY
•
If you include a GROUP BY clause, the columns you refer to in the select-list must be
either grouping columns or arguments of an aggregate (or set) function. For example, if
337).
"SEQUENCE BY Clause" (page
SELECT Statement
"Aggregate
326).
175