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
--
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.
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.
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
You could try this:
select id,list(Names,',' order by id) from TableName a group by id