Aggregates Aggregate

any_value()

Returns the first non-NULL value from arg. This function is affected by ordering.

Arguments & returns

2 overloads

any_value(arg)

Aggregate
Overload link arg Returns
#01 ANY ANY
#02 DECIMAL DECIMAL

In other engines

Apache Hivefirst()

SELECT FIRST(sample_col, TRUE)
In Haybarn
SELECT ANY_VALUE(sample_col)

SQLGlot example ↗

Apache Spark

SELECT ANY_VALUE(col, true), FIRST(col, true), FIRST_VALUE(col, true) OVER ()
In Haybarn
SELECT ANY_VALUE(col), ANY_VALUE(col), FIRST_VALUE(col IGNORE NULLS) OVER ()

SQLGlot example ↗

BigQueryany_value()

SELECT category, ANY_VALUE(product HAVING MAX price), ANY_VALUE(product HAVING MIN cost), ANY_VALUE(supplier) FROM products GROUP BY category
In Haybarn
SELECT category, ARG_MAX_NULL(product, price), ARG_MIN_NULL(product, cost), ANY_VALUE(supplier) FROM products GROUP BY category

SQLGlot example ↗

Prestoarbitrary()

ARBITRARY(x)
In Haybarn
ANY_VALUE(x)

SQLGlot example ↗