I have one output table -table A which looks like this
keys |
---|
key 1 |
key 2 |
SELECT keys
FROM table A
and i have another output table -table B which is result of aggregated function which is just having one row
agg |
---|
[1,2,3,4] |
SELECT agg_arr(columnX) as agg
FROM table A
what i want to do is i want to apply this aggregated result to all the rows in a new column in table A like this ( just a copy of the list )
keys | col |
---|---|
key 1 | [1,2,3,4] |
key 2 | [1,2,3,4] |
(both from the same table ) is there a way to do it? thank you
CodePudding user response:
You can try to use CROSS JOIN
SELECT t2.keys,t1.agg as col
FROM (
SELECT agg_arr(columnX) as agg
FROM tableA
) t1 CROSS JOIN tableA t2