Well you could look at the intarray extension and a combination of array_agg, uniq() and string_to_array:
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных