ARRAY_DISTINCT

All functions > ARRAY > ARRAY_DISTINCT

Returns an array with distinct elements, sorted in ascending order.

Syntax

ARRAY_DISTINCT(array)
sql

Arguments

ParameterTypeRequiredDescription
arrayARRAYBIGINTYesThe input array containing possible duplicate elements

Returns

An array with distinct elements sorted in ascending order

Notes

  • Removes all duplicate elements and sorts the result
  • Returns sorted distinct elements (unlike ARRAY_UNIQUE which may preserve order)
  • Eliminates all duplicates using set semantics
  • Handles NULL values consistently
  • Empty arrays remain empty

Examples

Last update at: 2025/10/13 10:23:46