---
title: any_value aggregate function
description: Learn the syntax of the any\_value aggregate function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/any_value
---

# `any_value` aggregate function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 11.3 LTS and above

Returns some value of `expr` for a group of rows. This function is non-deterministic.

## Syntax

```
any_value(expr[, ignoreNull]) [FILTER ( WHERE cond ) ] [ IGNORE NULLS | RESPECT NULLS ]
```

This function can also be invoked as a [window function](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-window-functions.md) using the `OVER` clause.

## Arguments

* `expr`: An expression of any type.
* `ignoreNull`: An optional BOOLEAN literal defaulting to false. The default for `ignoreNull` is false.
* `cond`: An optional boolean expression filtering the rows used for aggregation.
* `IGNORE NULLS` or `RESPECT NULLS`: When `IGNORE NULLS` is used or `ignoreNull` is `true` any `expr` value that is NULL is ignored.
  The default is `RESPECT NULLS`.

## Returns

The result has the same type as `expr`.

## Examples

```sql
> SELECT any_value(col) FROM VALUES (10), (5), (20) AS tab(col);
 10

-- Subsequent executions may yield a different results
> SELECT any_value(col) FROM VALUES (10), (5), (20) AS tab(col);
 20

> SELECT any_value(col) FROM VALUES (NULL), (5), (20) AS tab(col);
 NULL

> SELECT any_value(col) IGNORE NULLS FROM VALUES (NULL), (5), (20) AS tab(col);
 5
```

## Related

* [`min` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/min.md)
* [`max` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/max.md)
* [`last` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/last.md)
* [`first_value` aggregate function](https://docs.databricks.com/aws/en/sql/language-manual/functions/first_value.md)
* [Window functions](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-window-functions.md)
