Sybase ASE 15 Aggregate Function for strings

前端 未结 2 1240
清酒与你
清酒与你 2021-01-21 10:31

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
--          


        
相关标签:
2条回答
  • 2021-01-21 11:24

    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

    0 讨论(0)
  • 2021-01-21 11:24

    You could try this:

    select id,list(Names,',' order by id) from TableName a group by id 
    
    0 讨论(0)
提交回复
热议问题