0

Is there a function or query that could return arrays of different dimensions as a set? For example, I would like to return the values

ARRAY[1]
ARRAY[2,3]
ARRAY[4,5,6]

as

1
2
3
4
5
6
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
Nick
  • 555
  • 5
  • 22

2 Answers2

4

Use unnest():

SELECT unnest(arr) AS elem
FROM (
 VALUES
   (ARRAY[1])
  ,(ARRAY[2,3])
  ,(ARRAY[4,5,6])
  ) t (arr);

Returns as requested.
More details:

Community
  • 1
  • 1
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
0

try the following query

select unnest(a) from
(select array[1] as arr union select array[2,3]
union select array[4,5,6]) t

hopes this may be helpful :) ..

Srinu Chinka
  • 1,471
  • 13
  • 19