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