PostgresQL SQL: Converting results to array PostgresQL SQL: Converting results to array arrays arrays

PostgresQL SQL: Converting results to array


You want to use array_agg, this should work:

SELECT i_adgroup_id, array_agg(i_category_id)FROM adgroupcategories_brWHERE i_adgroup_id IN(    SELECT i_adgroup_id    FROM adgroupusers_br    WHERE i_user_id = 103713)GROUP BY i_adgroup_id;

Note that i_category_id is no longer in the GROUP BY as it is now being aggregated.