Description
Returns only the unique values aggregated as an array
Syntax
ARRAY_UNIQUE_AGG(expression)
Parameters
| Parameter | Description | Data Type | Required |
|---|---|---|---|
| expression | Column or expression to evaluate | Any | Yes |
Notes
- Works on any valid array type (
Integer[],Text[], etc.) - Preserves the order of the input array
- Returns NULL if the input array is NULL
- Use
WITHIN GROUP (ORDER BY ...)to control the order of unique values in the resulting array. - When used as a window function, include an
OVER (...)clause. - To filter rows based on a window calculation, use
QUALIFYinstead ofWHERE.
Example
SELECT
ARRAY_UNIQUE_AGG(full_name) WITHIN GROUP (ORDER BY full_name)
FROM
rippling.employee.Employee
GROUP BY
department;