title: Group by with case statement fails group by clause
body: <p>I have a table:</p>
  
  <pre><code>PROCEDURE
  ---------
  id  INT
  SERVICE_TYPE  VARCHAR(20)
  TIMEUNITS (INT)
  UNITS (INT)
  </code></pre>
  
  <p>I am trying to run this sql code:</p>
  
  <pre><code>select SERVICE_TYPE, 
         case when TIMEUNITS &gt; 1 THEN SUM(1) 
         WHEN UNITS &gt; 1 THEN SUM(UNITS) 
         END
  group by SERVICE_TYPE
  </code></pre>
  
  <p>My problem is that I"m told that TIMEUNITS is not grouped nor aggregated by...</p>
  
  <p>how do I repair this query?
  thanks</p>