APPLY_AVG
Returns the average of all elements in a with numeric values.
Returns the average of all elements in a collection (array or set) with numeric values.
Behavior type
ImmutableSyntax
APPLY_AVG(collection)
Arguments
collection
- Target collection
Supported data types
1D collections of:
-
INTEGER
-
INTERVAL
-
INTERVALYM
-
FLOAT
-
NUMERIC
Null-handling
The following cases return NULL:
-
if the input collection is NULL
-
if the input collection contains only null values
-
if the input collection is empty
If the input collection contains a mix of null and non-null elements, only the non-null values are considered in the calculation of the average.
Examples
=> SELECT apply_avg(ARRAY[1,2.4,5,6]);
apply_avg
-----------
3.6
(1 row)