\pset pager off
SELECT a.id, a.name, a.platform, a.status, a.schedulable, a.temp_unschedulable_until, a.temp_unschedulable_reason,
       COALESCE(string_agg(ag.group_id::text, ',' ORDER BY ag.group_id), '') AS groups
FROM accounts a
LEFT JOIN account_groups ag ON ag.account_id=a.id
WHERE a.id IN (181,195,212,215,218,219,1329,2347)
GROUP BY a.id, a.name, a.platform, a.status, a.schedulable, a.temp_unschedulable_until, a.temp_unschedulable_reason
ORDER BY a.id;
