Reputation: 2848
I'm trying to join all results from one column in SELECT
query into one string.
Some of you might be familiar with C#
:
string.Join(separator, stringArray)
The following statement doesn't return all results as one string
SELECT CONCAT(text) FROM orders
Does anyone have an idea of how to replicate that C#
code by means of SQL
?
Upvotes: 1
Views: 2501
Reputation: 1271231
You are looking for string_agg()
:
select string_agg(text separator, ',')
from orders;
Upvotes: 2