title: Subquery in group by (ORACLE 9i)
body: <p>I have a query that looks similar to the one below (albeit more complicated).  When running it I get the following error: <code>ORA-22818: Subquery expressions not allowed here</code> in my group by statement.</p>
  
  <p>What is the best way for me to get around this issue?</p>
  
  <pre><code>SELECT table1.ID   
         NVL(fget_office(fget_last_catc_id_by_date((SELECT MAX(table3.date) FROM table3 INNER JOIN table1 ON table1.ID = table3.id),table1.NUM), fget_max_split_line_no('FILL',(SELECT MAX table3.tc_id) FROM table3 INNER JOIN table1 ON table1.ID = table3.ID INNER JOIN table4 ON table3.tc_id = table3.tc_id))), table1.distribution) "OFFICE", --eper.DISTRIBUTION "OFFICE",
         table1.name 
    FROM table1
    LEFT JOIN table2
      ON table1.ID = table2.ID 
   WHERE table1.company in ('CP01', 'CP02')
   GROUP BY table1.ID,
            NVL(fget_office(fget_last_catc_id_by_date((SELECT MAX(table3.date) FROM table3 INNER JOIN table1 ON table1.ID = table3.id),table1.NUM), fget_max_split_line_no('FILL',(SELECT MAX table3.tc_id) FROM table3 INNER JOIN table1 ON table1.ID = table3.ID INNER JOIN table4 ON table3.tc_id = table3.tc_id))), table1.distribution),          
            table1.name
  </code></pre>