title: how to exclude null values in array_agg like in string_agg using postgres?
body: <p>If I use <code>array_agg</code> to collect names, I get my names separated by commas, but in case there is a <code>null</code> value, that null is also taken as a name in the aggregate. For example :</p>
  <pre><code>SELECT g.id,
         array_agg(CASE WHEN g.canonical = 'Y' THEN g.users ELSE NULL END) canonical_users,
         array_agg(CASE WHEN g.canonical = 'N' THEN g.users ELSE NULL END) non_canonical_users
  FROM groups g
  GROUP BY g.id;
  </code></pre>
  <p>it returns <code>,Larry,Phil</code> instead of just <code>Larry,Phil</code> (in my 9.1.2, it shows <code>NULL,Larry,Phil</code>).</p>
  <p>Instead, if I use <code>string_agg()</code>, it shows me only the names (without empty commas or nulls).</p>
  <p>The problem is that I have <code>Postgres 8.4</code> installed on the server, and <code>string_agg()</code> doesn't work there. <strong>Is there any way to make array_agg work similar to string_agg() ?</strong></p>