PostgreSQL json aggregation issue -


how postgres aggregation function merge 1 object element in array field in parent object.

what need

sector

sector

project

project

result

result

my sql request.

select row_to_json(t) ( select id, data, ( select array_to_json(array_agg(row_to_json(p))) ( select id, data public."project" (s.data -» 'projectid') :: uuid = id ) p ) projects public."sector" s ) t;

it don't work, because projects null. need, unwind data field , merge projectid in data project table. unwind , lookup in mongodb.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -