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.
ANY_VALUE(<expr>)
| Parameter | Description |
|---|---|
<expr> | The column or expression to be aggregated. |
Returns any non-NULL value if a non-NULL value exists, otherwise returns NULL.
select id, any_value(name) from cost2 group by id;
+------+-------------------+ | id | any_value(`name`) | +------+-------------------+ | 3 | jack | | 2 | jack | +------+-------------------+