If I have data like this in a table
id data
-- ----
1 1
1 2
1 3
2 4
2 5
3 6
3 4
How do I get results like this in a query (on sybase server)?
id data
-- ----
1 1, 2, 3
2 4, 5
3 6, 4
If I have data like this in a table
id data
-- ----
1 1
1 2
1 3
2 4
2 5
3 6
3 4
How do I get results like this in a query (on sybase server)?
id data
-- ----
1 1, 2, 3
2 4, 5
3 6, 4
I know that in MySQL there is GROUP_CONCAT and in Sybase I think it's LIST as stated in another answer:
For PostgreSQL, using a similar function string_agg.
You can't do this in a straight GROUP BY in plain-vanilla SQL. You have to use a cursor (or a similar construct) to concatenate the values in each group manually.
It's been a few years since I've tried using the syntax and I no longer have access to an iAnywhere instance, but there was an aggregate function (list) to do such a task. I cannot confirm if LIST() is still supported.
Try this one:
In MsSQL you can use a function (Don't know if there is somenthing similar in SyBase)
And then: