Lists & arrays
Scalar
list_distinct()
Removes all duplicates and NULLs from a list. Does not preserve the original order
Arguments & returns
list_distinct(list)
Scalar
| Overload link | list |
Returns |
|---|---|---|
| #01 | ANY[] |
ANY[] |
Example
Haybarn WASM 1.5.5-rc3 · In your browser
Engine example · Run to view results.
In other engines
Used in larger rewrites 1
These examples use list_distinct as one part of a larger SQL translation.
Snowflakearray_distinct()
SELECT ARRAY_DISTINCT(col)
SELECT CASE WHEN ARRAY_LENGTH(col) <> LIST_COUNT(col) THEN LIST_APPEND(LIST_DISTINCT(LIST_FILTER(col, _u -> NOT _u IS NULL)), NULL) ELSE LIST_DISTINCT(col) END