ARRAY_COUNT_DISTINCT

Returns the number of distinct (unique) elements in the array. As with COUNT and COUNT(DISTINCT ...) aggregations, NULL is not counted as a value if it occurs.

Syntax

ARRAY_UNIQ(<array>)

Parameters

Parameter Description Supported input types
<array> The array of which to count the distinct elements. Any ARRAY type

Return Type

INTEGER

Example

SELECT ARRAY_UNIQ([ 1, 2, 4, 5, 2, NULL, 5, 1 ]) AS res;

Returns: 4