Skip to main content

ARRAY_SUM

Sums the numeric elements in an array. NULL items are skipped, and non-numeric values raise an error.

Syntax

ARRAY_SUM(<array>)

Return Type

Numeric (matches the widest numeric type in the array).

Examples

SELECT ARRAY_SUM([1, 2, 3, 4]) AS total;

┌───────┐
│ total │
├───────┤
10
└───────┘
SELECT ARRAY_SUM([1.5, 2.25, 3.0]) AS total;

┌────────┐
│ total │
├────────┤
6.75
└────────┘
SELECT ARRAY_SUM([10, NULL, -3]) AS total;

┌───────┐
│ total │
├───────┤
7
└───────┘
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today