Skip to content
Advertisement

How to merge all integer arrays from all records into single array in postgres

I have a column which is of type integer array. How can I merge all of them into a single integer array?

For example: If I execute query:

I get result set as:

How can I get {1,2,3,4,5} as final result?

Advertisement

Answer

You could use unnest to open up the arrays and then array_agg to put them back together:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement