Skip to main content Skip to complementary content

arraySum

Calculates the sum of all the values in an array.

The arraySum function returns the sum of numeric values in a collection or array. This function operates on a single array value, ignoring null and missing values.

To calculate the sum across multiple rows in an iterative context, use the sum function instead.

Arguments

Array of numeric values.

Examples

Calculate the sum of prices stored in an array:
WITH $prices = ( FROM product SELECT price )
SELECT arraySum($prices)
Calculate the total of values in an array field:
FROM daily_sales
SELECT {
  date,
  total_sales = arraySum(sales_amounts)
}

Related functions

  • sum - Calculates the sum in an iterative context
  • arrayAvg - Calculates the average of values in an array

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!