Aggregate Functions

Aggregate functions generate summary values that appear as new columns in the query results. They can be used in a select list or the having clause of a select statement or subquery.

When an aggregate function is applied to a char datatype value, it implicitly converts the value to varchar, stripping all trailing blanks. In a similar manner, a unichar datatype value is implicitly converted to univarchar.

Limitations

  • Aggregate functions cannot be used in a where clause.
  • Because each aggregate in a query requires its own worktable, an aggregate query cannot exceed the maximum number (46) of worktables allowed in a query.

  • If you include an aggregate function in the select clause of a cursor, that cursor cannot be updated

  • You cannot use aggregate functions on virtual tables such as sysprocesses and syslocks.