Aggregate functions
An aggregate function is an SQL-invoked function that takes values that depend on all the rows that the query selects and returns information about these rows. The database server supports aggregate functions that you write, called user-defined aggregates. You can write user-defined aggregates in SPL or in external languages.
- The database server provides built-in aggregate functions, such
as COUNT, SUM, or AVG, that operate on built-in data types.
You cannot create a user-defined aggregate that has the same name as a built-in aggregate and that handles a built-in data type. However, you can define a new aggregate that operates on a built-in data type.
- When you create a UDT, you can write user-defined aggregates to
provide aggregates that handle this data type. The database server
provides two ways to extend aggregates:
- Extend a built-in aggregate to handle the data type.
You overload the support functions for the built-in aggregate.
- Define a new aggregate.
You write a user-defined aggregate with a name that is different from any existing aggregate function. You then register a new aggregate in the database.
- Extend a built-in aggregate to handle the data type.
For more information about aggregate functions, see Create user-defined aggregates. Aggregate functions use the support functions to compute the aggregate result. For information about support functions, see Write support functions.