I like to change the brackets "{" and "}" to "[" and "]" in the following example. I have a table A with two coloumns, one is text_1 of type string and the second is count of type bigint. What I'm trying to do is to return a matrix notation like [[1,2,4],[2,4,5],...].
CREATE AGGREGATE array_agg_mult(anyarray) (
SFUNC = array_cat,
STYPE = anyarray,
INITCOND = '{}'
);
WITH B AS(
SELECT
array_agg(count) AS count
FROM
A
GROUP BY
text_1
)
SELECT
array_agg_mult(ARRAY[count])
FROM
B;
Besides how to update array_agg_mult, if I try to change INITCOND = '{}' to INITCOND = '[]' I get the
ERROR: function "array_agg_mult" already exists with same argument types
Maybe there is a smart solution by using json generation with postgres.