/**************************************
**函数:listagg
**作用:列连接
**时间:2016-7-8
**内容:语法和使用案例
**************************************/
–1 语法
listagg(measure_expr,’delimiter’) within group (order_by_clause) over(query_partition_clause)
–注意:order_by_clause不在over()里面
–注:语法解读
The arguments to the function are subject to the following rules:
•The measure_expr can be any expression. Null values in the measure column are ignored.
•The delimiter_expr designates the string that is to separate the measure values. This clause is optional and defaults to NULL.
定界符
•The order_by_clause determines the order in which the concatenated values are returned. The function is deterministic only if the ORDER BY column list achieved unique ordering.
The return data type is RAW if the measure column is RAW; otherwise the return value is VARCHAR2

本文详细介绍了Oracle中的分析函数listagg和wmsys.wm_concat,用于实现列连接操作。listagg函数允许指定排序依据,并在每个组内按顺序连接值,返回类型为RAW或VARCHAR2。示例展示了如何在查询中应用这两个函数,通过PARTITION BY进行分组并连接out_row列的值。
最低0.47元/天 解锁文章
4207

被折叠的 条评论
为什么被折叠?



