Documentation

    list_reduce

    Reduces all elements of the input list into a single scalar value by executing the lambda function on a running result and the next list element. The lambda function has an optional initial_value argument.

    Also available as array_reduce, reduce.

    Try an expression

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

    Expression

    list_reduce([1, 2, 3], lambda x, y : x + y)

    Result

    6

    To use your own data, replace the example values with column names. Keep format strings and other options as written.

    Arguments and types

    list_reduce(list, lambda(x,y), initial_value)
    list
    List
    lambda(x,y)
    Lambda expression
    initial_value
    Any value
    Supported signatures (2)
    list_reduce(list: ANY[], lambda(x,y): LAMBDA) → ANY
    list_reduce(list: ANY[], lambda(x,y): LAMBDA, initial_value: ANY) → ANY

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

    Things to know

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

    Browse lists & arraysDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.