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

  1. mysql> select * from test_doris_array_agg;
  2. +------+------+
  3. | c1 | c2 |
  4. +------+------+
  5. | 1 | a |
  6. | 1 | b |
  7. | 2 | c |
  8. | 2 | NULL |
  9. | 3 | NULL |
  10. +------+------+
  11. mysql> select c1, array_agg(c2) from test_doris_array_agg group by c1;
  12. +------+-----------------+
  13. | c1 | array_agg(`c2`) |
  14. +------+-----------------+
  15. | 1 | ["a","b"] |
  16. | 2 | [NULL,"c"] |
  17. | 3 | [NULL] |
  18. +------+-----------------+

keywords

ARRAY_AGG