# ARRAY_UNIQUE_AGG() Function

### Description

Returns only the unique values aggregated as an array

### Syntax

```sql
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 `QUALIFY` instead of `WHERE`.

### Example

```sql
SELECT
    ARRAY_UNIQUE_AGG(full_name) WITHIN GROUP (ORDER BY full_name)
FROM
    rippling.employee.Employee
GROUP BY
    department;
```

Source: https://developer.rippling.com/documentation/rippling-platform/transformations/sql-reference/array_unique_agg

> For the complete documentation index, see [llms.txt](https://developer.rippling.com/llms.txt). Public pages have a Markdown version at the same URL with .md added.
