ARRAY_AGG

All functions > AGGREGATE > ARRAY_AGG

Returns an array of the values in the group.

Syntax

ARRAY_AGG(expr: T) → ARRAY<T>
sql

Type Parameters:

  • T: Any hashable type

Arguments

ParameterTypeRequiredDescription
exprTYesThe expression to aggregate into an array

Returns

Array containing all values from the group

Notes

  • Collects all values in a group into a single array
  • Supports ORDER BY to control the order of elements in the result array
  • Supports LIMIT to restrict the number of elements
  • Can be combined with WHERE clause to filter values before aggregation
  • NULL values are included in the result array
  • Returns empty array if group has no values
  • Use with GROUP BY to create arrays per group

Examples

Last update at: 2025/10/13 10:23:46