ARRAY_DISTINCT
functionsupportedCore SQL functionsReturns a new ARRAY that contains only the distinct elements from the input ARRAY. The function excludes any duplicate elements that are present in the input ARRAY. The function is not guaranteed to return the elements in the ARRAY in a specific order. The function is NULL-safe, which means that it treats NULLs as known values when identifying duplicate elements.
Syntax
ARRAY_DISTINCT( <array> )
Parameters
| Name | Required | Description |
|---|---|---|
array | required | An array that might contain duplicate elements to be removed. |
Returns
This function returns an ARRAY that contains the elements of the input array without any duplicate elements. For example, if the value 'x' appears multiple times in the input ARRAY, only one element has the value 'x' in the returned ARRAY. If the input argument is NULL, the function returns NULL. The order of the values within the returned array is unspecified.
Usage notes
- For elements of the type OBJECT, the objects must be identical to be considered duplicate. For details, see Examples (in this topic).
- When identifying duplicate elements, the function considers NULL to be a known value (i.e. NULL is not a duplicate of any other value X besides NULL).