字符串的Sybase ASE 15聚合函数 [英] Sybase ASE 15 Aggregate Function for strings
问题描述
我找到了一种将不同行中的字符串聚合到sybase ASE 15中的单行中的方法。
I'am findind a way to aggregate strings from differents rows into a single row in sybase ASE 15. Like this:
id | Name Result: id | Names
-- - ---- -- - -----
1 | Matt 1 | Matt, Rocks
1 | Rocks 2 | Stylus
2 | Stylus
类似于T-SQL中的FOR XML PATH。
Something like FOR XML PATH in T-SQL.
谢谢!
推荐答案
Sybase ASE没有诸如 list( )
或 group_concat()
;尽管对 FOR XML
有一些支持,但不包括对 PATH
选项/功能的支持。
Sybase ASE does not have any string aggregate functions like list()
or group_concat()
; and while there is some support for FOR XML
, it does not include support for the PATH
option/feature.
假设要追加的行数未知/可变,则唯一的(ASE 15)T-SQL选项将是基于游标的解决方案。
Assuming you could have an unknown/variable number of rows to append, your only (ASE 15) T-SQL option would be a cursor-based solution.
如果发现自己正在使用ASE 16,则可以编写用户定义函数(UDF)来完成任务,例如:在ASE 16中模拟group_concat()
If you find yourself working with ASE 16 you could write a user-defined function (UDF) to accomplish the task, eg: emulate group_concat() in ASE 16
这篇关于字符串的Sybase ASE 15聚合函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!