【发布时间】:2020-03-28 23:58:55
【问题描述】:
我可以使用LISTAGGconcatenate column values from multiple rows in Oracle
但我想避免重复
目前它返回重复项
select LISTAGG( t.id,',') WITHIN GROUP (ORDER BY t.id) from table t;
例如数据
ID
10
10
20
30
30
40
返回10,10,20,30,40,40
改为10,20,30,40
我不能在LISTAGG 中使用distinct
select LISTAGG( distinct t.id,',') WITHIN GROUP (ORDER BY t.id) from table t;
错误
ORA-30482: DISTINCT option not allowed for this function
【问题讨论】:
标签: sql oracle duplicates string-concatenation listagg