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 

1ARRAY_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.

1SELECT 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 

DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!