Aggregate functions are objects whose main goal is to compute a single result from a set of input values. PostgreSQL offers a good set of built-in aggregates but due to the extensibility of the database system the user is able to create custom aggregates too. The main attributes of this kind of object are described below.
|The function used to compute the final result of the aggregate when all input was processed. This function must take a single argument of the same type as the one configured on the
Function State tab. The return type of the aggregate will be the same as the return type of this function.
|The state transition function that is used to compute the current aggregate result for each input row. This function can have more than one argument but the first must be the same as the one configured on the
Function State tab as well for the function's return type.
|An optional sort operator used for aggregates that works like
MAX functions. The input data type for the operator must be the same as the configured for the aggregate itself.
|This attribute stores the initial value for the state data type configured on the
Function State tab. The value informed here must be formatted according to the way accepted by the data type.
|This tab configures the set of input data types accepted by the aggregate. To create a zero-argument aggregate (e.g.
count(*)) leave this field empty.
|Configures the state data type for the aggregate. This data type is used to create a temporary variable while the aggregate is running over the set of rows.