title: PostgresQL SQL: Converting results to array
body: <p>The query below:</p>
  
  <pre><code>    SELECT  i_adgroup_id, i_category_id
      FROM adgroupcategories_br
      WHERE i_adgroup_id IN
      (
          SELECT i_adgroup_id
          FROM adgroupusers_br
          WHERE i_user_id = 103713
      )
      GROUP BY i_adgroup_id, i_category_id;
  </code></pre>
  
  <p>Gives me results like this:</p>
  
  <pre><code>    i_adgroup_id integer | i_category_id smallint
      ---------------------|-----------------------
      15938                | 2
      15938                | 3
      15938                | 4
      15942                | 1
      15942                | 2
  </code></pre>
  
  <p>What I want is results like this:</p>
  
  <pre><code>    i_adgroup_id integer | i_category_id smallint[]
      ---------------------|-----------------------
      15938                | { 2, 3, 4 }
      15942                | { 1, 2 }
  </code></pre>
  
  <p>How can I change the original SQL query to give me the result above?</p>