Is there a equivalent function in Sybase ASE to the group_concat of MYSQL?
Sybase ASE中是否有与MYSQL的group_concat等价的函数?
3 个解决方案
#1
3
No,
不,
you have to create a stored procedure.
您必须创建一个存储过程。
#2
1
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.
更好的方法是创建一个游标,每次只处理一行,可以进入存储过程。假定游标查询通过order by子句对数据进行排序,然后通过group_concat = group_concat +字段等表达式连接数据。
You have the power!
你有能力!
Good SQL, good night.
良好的SQL,晚安。
#3
1
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.
这个查询将对“column_to_concat”列中的行进行concat,您可以使用逗号、斜杠等更改空间分隔符。
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
#1
3
No,
不,
you have to create a stored procedure.
您必须创建一个存储过程。
#2
1
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.
更好的方法是创建一个游标,每次只处理一行,可以进入存储过程。假定游标查询通过order by子句对数据进行排序,然后通过group_concat = group_concat +字段等表达式连接数据。
You have the power!
你有能力!
Good SQL, good night.
良好的SQL,晚安。
#3
1
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.
这个查询将对“column_to_concat”列中的行进行concat,您可以使用逗号、斜杠等更改空间分隔符。
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