MYSQL group_concat equivalent in Sybase ASE?

梦想与她 提交于 2019-12-02 01:23:00

问题


Is there a equivalent function in Sybase ASE to the group_concat of MYSQL?


回答1:


No,

you have to create a stored procedure.




回答2:


Better yet create a cursor that processes one row at a time which could go into a stored procedure. The cursor query is assumed to sort the data via the order by clause and then concatenates the data via an expression like group_concat = group_concat + field.

You have the power!

Good SQL, good night.




回答3:


This query will concat the rows in the "column_to_concat" column, you can change the space separator character with commas, slash, etc. In this case i choose space because with trim i can get rid off the spaces at the start and end of the output.

SELECT column_to_concat
INTO #table_temp
FROM table

DECLARE @data VARCHAR(100)

UPDATE #table_temp
SET @data = @data + ' ' + column_to_concat

SELECT LTRIM(RTRIM(@data))

DROP TABLE #table_temp


来源:https://stackoverflow.com/questions/8230712/mysql-group-concat-equivalent-in-sybase-ase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!