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
| Parameter | Description |
|---|---|
<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
-- setup
create table cost2(id int, name varchar(20)) distributed by hash(id) buckets 1 properties ("replication_num"="1");
insert into cost2 values (2,'jack'),(3,'jack');
select id, any_value(name) from cost2 group by id;
+------+-------------------+
| id | any_value(`name`) |
+------+-------------------+
| 3 | jack |
| 2 | jack |
+------+-------------------+