【发布时间】:2017-02-10 21:51:43
【问题描述】:
我必须连接下面的数据
a b c
1 Text 22-03-2015
1 Text1 22-03-2015
2 Text2 24-05-2015
3 Text5 29-05-2015
1 Text11 23-03-2015
而预期的输出是
a b c
1 Text,text1 22-03-2015
1 Text11 23-03-2016
2 Text2 24-05-2015
3 Text5 29-05-2015
尝试了 wm_concat 函数,它可以工作,但我无法从数据中删除重复项,并且 LISTAGG 的使用会导致错误
"ora-01489 oracle中字符串连接的结果太长"
错误,因为 b 列包含大于 4000 个字符的值。
除了这两个功能之外,还有其他选择吗?
【问题讨论】:
-
一种选择是使用带有
distinct的子查询。这可能会有所帮助:stackoverflow.com/questions/19577257/… -
Distinct 不起作用。这个查询本身就是一个子查询。
-
从您的示例数据中不清楚原因。您应该提供说明您遇到的问题的示例数据。也许创建一个 sqlfiddle.com 来演示。
-
SELECT a ,to_char(c,'DD.MM.YYYY') enddate ,type ,wm_concat( type || ': (' || to_char (c,'HH:MI:SS AM' ) || ') ' || b ) 输出表 GROUP BY a ,to_char(c,'DD.MM.YYYY') ,type
-
是我正在使用的子查询
标签: sql oracle concatenation