PostgreSQL query to return results as a comma separated list November 30, 2022 by Tarik SELECT string_agg(id::text, ',') FROM table Requires PostgreSQL 9.0 but that’s not a problem.