Jacek
Jacek

Reputation: 12053

Convert query result to array

How can convert result from query to array. For example

select ARRAY[x."Id"] as "id"
from public."jp_OnlyIds" as x

In above code, I get many rows with single element array, I want to get one array with all element, how can I do this?

I use Posgres database

Upvotes: 1

Views: 148

Answers (1)

kiks73
kiks73

Reputation: 3778

You can try this:

select array_agg(x."id")  as "id" from public."jp_OnlyIds" as x

Upvotes: 2

Related Questions