How to aggregate two PostgreSQL columns to an array separated by brackets
Create an array from the two columns, the aggregate the array: select id, array_agg(array[x,y]) from the_table group by id; Note that the default text representation of arrays uses curly braces ( {..}) not square brackets ([..])