ARRAY_SUM

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate functionsSemi-structured and structured data functions

Aggregates a column of structured ARRAY values by summing them element by element. The value at each position in the result is the sum of the values at that position across all of the input arrays. Unlike SUM, which adds up scalar values, this function adds up arrays position by position and returns an array. Unlike VECTOR_SUM, which operates on 32-bit VECTOR values, this function operates on structured arrays of 64-bit floating-point elements.

Syntax

ARRAY_SUM( <array> )

Parameters

NameRequiredDescription
arrayrequiredA column of structured ARRAY values whose element type is floating-point: ARRAY(FLOAT), ARRAY(DOUBLE), or ARRAY(REAL).

Returns

Returns a structured ARRAY with the same element type as the input. Each element in the result is the sum of the elements at the corresponding position across all of the input arrays. The function returns NULL if the group contains no rows or if every value in the group is NULL.

Usage notes

See also

Referenced by