Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sybase ASE 15 Aggregate Function for strings

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

Something like FOR XML PATH in T-SQL.

Thanks!

like image 413
Herman Zun Avatar asked Oct 17 '25 00:10

Herman Zun


1 Answers

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

like image 106
markp-fuso Avatar answered Oct 18 '25 15:10

markp-fuso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!