quack
quack

Reputation: 383

how to get rows value in one row?

Select id
from x

gives a list of ids:

1
2
3
44
655
31

how Do i get it in one row as array? like (1,2,3,44,655,31)

Upvotes: 1

Views: 78

Answers (2)

Chendur
Chendur

Reputation: 1159

SQLFiddle Demo

SELECT 
array_to_string(array_agg(id),',') as agg_id 
from x

Upvotes: 1

Thanga
Thanga

Reputation: 8161

Query should be like this

 SELECT string_agg(id, ',') FROM x

Upvotes: 1

Related Questions