postgres multiple left join causing duplicates jsonb agg

Solutions on MaxInterview for postgres multiple left join causing duplicates jsonb agg by the best coders in the world

showing results for - "postgres multiple left join causing duplicates jsonb agg"
Stefania
03 Mar 2016
1SELECT tbl_a.id, tbl_a.name,
2       COALESCE( ( SELECT json_agg(tbl_b.*)
3                     FROM tbl_b 
4                    WHERE tbl_b.a_id = tbl_a.id ), '{}'::json),
5       COALESCE( ( SELECT json_agg(tbl_c.*)
6                     FROM tbl_c 
7                    WHERE tbl_c.a_id = tbl_a.id ), '{}'::json)
8  FROM tbl_a;
9
similar questions