Lists & arrays Aggregate

array_agg()

Returns a LIST containing all the values of a column.

Alias of list()

Arguments & returns

array_agg(arg)

Aggregate
Overload link arg Returns
#01 T T[]

Example

array_agg example
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Engine example with sample data · Run to view results.

In other engines

Apache Hivecollect_list()

COLLECT_LIST(x)
In Haybarn
ARRAY_AGG(x) FILTER(WHERE x IS NOT NULL)

SQLGlot example ↗

Apache Sparkarray_agg()

Same function

BigQueryarray_agg()

SELECT ARRAY_AGG(x IGNORE NULLS) AS x
In Haybarn
SELECT ARRAY_AGG(x) FILTER(WHERE x IS NOT NULL) AS x

SQLGlot example ↗

Snowflakearray_agg()

SELECT ARRAY_AGG(DISTINCT a)
In Haybarn
SELECT ARRAY_AGG(DISTINCT a) FILTER(WHERE a IS NOT NULL)

SQLGlot example ↗