Select to 2D Array

In PostgreSQL, how can I select some values ​​in a 2D array?

For example, if I want to aggregate a data field into an array, I would use the ARRAY () constructor or the array_agg function, for example.

ARRAY(SELECT s.name FROM myschema.mytable s)

How can I select, say, two values, in a 2D array, i.e.

2DARRAYFUNCTION(SELECT s.name, s.id FROM ...)
+5
source share
2 answers

If you try to combine ARRAY(build from a key and values, as in your example), into a two-dimensional array, an assembly array_agg()or constructor assembly error ARRAY:

I accidentally wrote an answer for this case . Turns out this is your prequel question.

+3
source

Check the documentation HERE .

0
source

All Articles