Edit

Share via


ARRAY_SUM (NoSQL query)

APPLIES TO: NoSQL

Returns the sum value of elements in the specified array expression.

Syntax

ARRAY_SUM(<array_expr>)  

Arguments

Description
array_expr An array expression.

Return types

Returns a numeric expression.

Examples

The following example shows the results of using this function on arrays with numeric values.

SELECT VALUE {
    "case1": ARRAY_SUM([1, 2, 3, 4]),
    "case2": ARRAY_SUM([1, 2, 3, 4, undefined]),
    "case3": ARRAY_SUM(['abc', 'ABC', 'aBc', 'AbC']),
    "case4": ARRAY_SUM([12, 'abc', true, false, null, undefined])
}
[
    {
        "case1": 10,
        "case2": 10
    }
]

Remarks

  • The elements in array can only be number.
  • Any undefined values are ignored.
  • This function performs a full scan.