listagg 函数将组内的数据通过 order by 排序后,再连接到一起,可以指定分隔符。输入多行,输出一行或多行。常用来将值连接成逗号分隔的数据。
语法:
三个使用场景:
-
As a single-set aggregate function,
LISTAGG
operates on all rows and returns a single output row. -
As a group-set aggregate, the function operates on and returns an output row for each group defined by the
GROUP
BY
clause. -
As an analytic function,
LISTAGG
partitions the query result set into groups based on one or more expression in thequery_partition_clause
.
场景2,根据 grou