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;

3. +------+------+

5. | c1   | c2   |

7. +------+------+

9. |    1 | a    |

11. |    1 | b    |

13. |    2 | c    |

15. |    2 | NULL |

17. |    3 | NULL |

19. +------+------+

21. mysql> select c1, array_agg(c2) from test_doris_array_agg group by c1;

23. +------+-----------------+

25. | c1   | array_agg(`c2`) |

27. +------+-----------------+

29. |    1 | ["a","b"]       |

31. |    2 | [NULL,"c"]      |

33. |    3 | [NULL]          |

35. +------+-----------------+

keywords

ARRAY_AGG