3

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

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
aF.
  • 64,980
  • 43
  • 135
  • 198

3 Answers3

3

No,

you have to create a stored procedure.

kolchanov
  • 2,018
  • 2
  • 14
  • 32
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.

You have the power!

Good SQL, good night.

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.

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
Herman Zun
  • 471
  • 1
  • 6
  • 21