title: LISTAGG Query "ORA-00937: not a single-group group function"
body: <p>I'm trying to create a join with a list of comma separated values. For example:</p>
  
  <pre><code>rule_id | attribute_id
  ----------------------
  1       | a
  1       | b
  2       | c
  2       | d
  </code></pre>
  
  <p>should be:</p>
  
  <pre><code>rule_id | attribute_id
  ----------------------
  1       | a,b
  2       | c,d
  </code></pre>
  
  <p>I am attempting to do so using <code>LISTAGG</code>. However, with the below code, I'm getting <code>ORA-00937: not a single-group group function</code>. I noticed a <code>FOR PATH</code> syntax for sql-server, but it doesn't look like that works for our configuration. Here's my query:</p>
  
  <pre><code>SELECT r.rule_id as RULE_ID, 
  LISTAGG(a.ATTRIBUTE_ID, ', ') WITHIN GROUP (ORDER BY a.ATTRIBUTE_ID) "ATTR_IDS"
  FROM N_RULE r, N_ATTRIBUTE a 
  WHERE r.RULE_ID = a.RULE_ID 
  ORDER BY r.AUDIENCE, UPPER(r.NAME);
  </code></pre>