0

My question is the following ;

After a first query, I have a table with a single column of bigints, for example :

 id 
----
  1
  2
  3
  4

I would like to convert this column into a postgresql array, which would give - according to the example - {1,2,3,4}.

Any ideas about how to do that ?

Thank you for all your answers and have a nice day, best regards

1 Answer 1

1

Use aggregation:

select array_agg(id)
from the_table;

If you need a specific sort order:

select array_agg(id order by id)
from the_table;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.