Link Search Menu Expand Document

ANY_VALUE

Returns a single arbitrary value from the specified column. This function ignores NULLs, so the only time it will return NULL is when all inputs are NULLs.

Syntax

ANY_VALUE(<col>)
Argument Description Data Type
<col> The column from which the value is returned. Any
Return Type

Same as input argument

Example

Consider a table, example_table, with a single column first_name as shown below.

+------------+
| first_name |
+------------+
| Sammy      |
| NULL       |
| Carol      |
| Lei        |
| Mickey     |
+------------+

The first time the query below runs, Carol might be returned. The second time the query runs, Carol or any other value, such as Lei or Sammy, might be returned, but NULL will never be returned.

SELECT
	ANY_VALUE(first_name)
FROM
	example_table;