Aggregate functions
An aggregate function computes a single result value from a set of values. The following table
describes the aggregate functions.
| Function | Description |
|---|---|
| count | Counts all rows. |
| sum | Provides a total. |
| max | Returns the maximum value. The aggregate function takes one input value, which is typically a
column name or other single name that represents a set. For example, max(AGE) returns the largest
value in the column named AGE. Note: If you specify two or more input values, the system
uses the max() scalar function to return the maximum of all the values. See Functions for a description of the scalar
function.
|
| median | Returns the median or middle value of a set of numbers. If the set has an even number of members, the function returns the average of the two middle members of the set. Null values are ignored. |
| min | Returns the minimum value. The aggregate function takes one input value, which is typically a
column name or other single name that represents a set. For example, min(AGE) returns the lowest
value in the column named AGE. Note: If you specify two or more input values, the system
uses the min() scalar function to return the minimum of all the values. See Functions for a description of the scalar
function.
|
| avg | Averages the values. The averages of exact numeric types are computed to 6 decimal places. |
The following table describes data types that can be
specified as arguments for aggregate functions.
| Data type | Function |
|---|---|
| JSON | count |
| Other data types | count, max, min |
| Numeric only | avg, sum |
| Numeric and interval data types | median |