Link Search Menu Expand Document


If one argument is passed, returns the number of different elements in the array. If multiple arguments are passed, returns the number of different tuples of elements at corresponding positions in multiple arrays.


ARRAY_UNIQ(<arr> [, ...n])
Parameter Description
<arr> [, ...n] The array or arrays to be analyzed.


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

Returns: 4

Example–using multiple arrays

When using multiple arrays, ARRAY_UNIQ evaluates all the elements at a specific index as tuples for counting the unique values.

For example, two arrays [1,1,1,1] and [1,1,1,2] would be evaluated as individual tuples (1,1), (1,1), (1,1), and (1,2). There are 2 unique tuples, so ARRAY_UNIQ would return a value of 2.

	ARRAY_UNIQ ([ 1, 1, 1, 1 ], [ 1, 1, 1, 2 ]) AS res;

Returns: 2

In the example below, there are three different strings across all of the elements of the given arrays. However, there are only two unique tuples, (‘apple’, ‘pie’) and (‘apple’, ‘jack’).

		[ 'apple',
		'apple' ],
		[ 'pie',
		'jack' ]
	) AS res;

Returns: 2