APPLY_SUM

Computes the sum of all elements in a collection (array or set).

Behavior Type

Immutable

Syntax

APPLY_SUM(collection)

Supported Data Types

1D collections of:

  • INTEGER
  • FLOAT
  • NUMERIC
  • INTERVAL

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

Example

=> SELECT apply_sum(ARRAY[12.5,3,4,1]);
apply_sum
-----------
      20.5
(1 row)

See also