Aggregates
Aggregate
any_value()
Returns the first non-NULL value from arg. This function is affected by ordering.
Arguments & returns
2 overloadsany_value(arg)
Aggregate
In other engines
Apache Hivefirst()
SELECT FIRST(sample_col, TRUE)
SELECT ANY_VALUE(sample_col)
Apache Spark
SELECT ANY_VALUE(col, true), FIRST(col, true), FIRST_VALUE(col, true) OVER ()
SELECT ANY_VALUE(col), ANY_VALUE(col), FIRST_VALUE(col IGNORE NULLS) OVER ()
BigQueryany_value()
SELECT category, ANY_VALUE(product HAVING MAX price), ANY_VALUE(product HAVING MIN cost), ANY_VALUE(supplier) FROM products GROUP BY category
SELECT category, ARG_MAX_NULL(product, price), ARG_MIN_NULL(product, cost), ANY_VALUE(supplier) FROM products GROUP BY category