Използвайте json_agg() и jsonb_array_elements() функции:
select json_agg(cell)
from (
select jsonb_array_elements(elem->'cell') cell
from (
select jsonb_array_elements(data->'cust') elem
from product_cust
) subsub
) sub
Можете да обедините две вътрешни подзаявки:
select json_agg(cell)
from (
select jsonb_array_elements(jsonb_array_elements(data->'cust')->'cell') cell
from product_cust
) sub
Групирайте резултатите по productid:
select productid, json_agg(cell)
from (
select productid, jsonb_array_elements(jsonb_array_elements(data->'cust')->'cell') cell
from product_cust
) sub
group by 1
order by 1