ARRAY_DISTINCT

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Returns an array with duplicate elements removed, preserving the first occurrence of each element.

Syntax

array_distinct(<array>)

Arguments

Required

  • <array>: The source array.

Returns

Returns an array that contains only unique elements, with the first occurrence of each element preserved.

Considerations

  • Keeps only the first occurrence of each duplicate element.
  • Preserves the relative order of elements.

Examples

Remove Duplicates

Get unique values from an array with duplicates.

SELECT array_distinct(array[1, 2, 1, 3]) AS result;

Returns array[1, 2, 3], removing the duplicate 1 and keeping the first occurrence.

Related Documentation