Restrictions on the Use of Aggregate Functions
The following restrictions apply to the use of aggregate functions:
• Aggregate functions cannot be nested.
• Aggregate functions can only be used in select or having clauses.
• If a select or having clause contains an aggregate function, columns not specified in the aggregate must be specified in the group by clause. For example:
select dept, avg(emp_age)
from employee
group by dept;
The above select statement specifies two columns, dept and emp_age, but only emp_age is referenced by the aggregate function, avg. The dept column is specified in the group by clause.