Skip to main content

ANY_VALUE

Description​

Returns any value from the expression or column in the group. If there is a non-NULL value, it returns any non-NULL value; otherwise, it returns NULL.

Alias​

  • ANY

Syntax​

ANY_VALUE(<expr>)

Parameters​

ParameterDescription
<expr>The column or expression to be aggregated.

Return Value​

Returns any non-NULL value if a non-NULL value exists, otherwise returns NULL.

Example​

select id, any_value(name) from cost2 group by id;
+------+-------------------+
| id | any_value(`name`) |
+------+-------------------+
| 3 | jack |
| 2 | jack |
+------+-------------------+