I am looking for a way to concatenate the strings of a field within a group by query. So for example, I have a table: and I wanted to group by company_id to get something like: There is a built-in function in mySQL to do this group_concat Answer PostgreSQL 9.0 or later: Modern Postgres (since 2010) has the string_agg(expression, delimiter)