Skip to main content Skip to complementary content

arrayAvg

Calculates the average value of an array.

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

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

Arguments

Array of numeric values.

Examples

Calculate the average of ratings stored in an array:
WITH $ratings = ( FROM customer SELECT rating )
SELECT arrayAvg($ratings)
Calculate the average of scores in an array field:
FROM test_results
SELECT {
  student_id,
  average_score = arrayAvg(scores)
}

Related functions

  • avg - Calculates the average in an iterative context
  • arraySum - Calculates the sum 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!