Documentation

    list_distinct

    Remove duplicates and missing values from a list. The original order isn't kept.

    Also available as array_distinct.

    Try an expression

    In Formula, enter the expression and set Output type to VARCHAR.

    Expression

    list_distinct([1, 1, NULL, -3, 1, 5])

    Result

    '[5, -3, 1]'

    The expression returns INTEGER[]. Formula stores it as VARCHAR in this example. To use your own data, replace the example values with column names. Keep format strings and other options as written.

    Arguments and types

    list_distinct(list)
    list
    List
    Supported signatures (1)
    list_distinct(list: T[]) → T[]

    The result type can depend on the input types. See DuckDB for the full argument rules.

    Things to know

    Duplicate and missing elements are removed. Don't rely on the order of the remaining elements; use list_sort when order matters.

    If the first argument is missing, the result is NULL.

    Sort the remaining values

    list_sort(list_distinct([1, 1, NULL, 3, 2]))

    '[1, 2, 3]'

    Browse lists & arraysDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.