postgresql concatenate multiple rows into one row
SELECT movie, string_agg(actor, ', ') AS actor_list FROM tbl GROUP BY 1;
Source: stackoverflow.com
postgresql concatenate multiple rows in group by
SELECT col_a, array_to_string(array_agg(distinct col_b),',') AS Actor FROM Table1 GROUP BY col_a; -- Result: -- MOVIE ACTOR -- A 1,2,3 -- B 4
Source: stackoverflow.com