ARRAY_AGG
ARRAY_AGG
description
Syntax
ARRAY_AGG(col)
Concatenation of values in a column (including the null value) into an array can be used for multiple rows to one row (row to column).
notice
- The order of the elements in an array is not guaranteed.
- Returns the array generated by the transformation. The element type in the array is the same as the col type.
example
mysql> select * from test_doris_array_agg;
+------+------+
| c1 | c2 |
+------+------+
| 1 | a |
| 1 | b |
| 2 | c |
| 2 | NULL |
| 3 | NULL |
+------+------+
mysql> select c1, array_agg(c2) from test_doris_array_agg group by c1;
+------+-----------------+
| c1 | array_agg(`c2`) |
+------+-----------------+
| 1 | ["a","b"] |
| 2 | [NULL,"c"] |
| 3 | [NULL] |
+------+-----------------+
keywords
ARRAY_AGG