I have a table with arrays of integer.
I want to create an aggregate function that will return a 2-dimensional array with all the rows together. It then gets passed
Using the built-in array_cat function works.
CREATE AGGREGATE array_sum2 (int[]) (
SFUNC = array_cat,
STYPE = int[],
INITCOND = '{}'
);
test:
select array_sum2(array[d.a]) from (select array[1,1,2,3] as a union select array[5,8,13,21] as a) d;
array_sum2
-------------------------
{{1,1,2,3},{5,8,13,21}}