title: "column XYZ must be in group by" --> "cannot group by aggregate column"
body: <p>i have trouble with following sql-statement (trimmed):</p>
  
  <pre><code>SELECT nr,
      (CASE WHEN 
          SUM(vkdtab.amount*liter)&lt;&gt;0 AND 
          jjjjmm BETWEEN 201001 and 201009 
      THEN SUM(net)/SUM(vkdtab.amount*liter) 
      ELSE 0 END) as return
  FROM tab
  GROUP BY 1,2,3
  </code></pre>
  
  <p>It should give me the amount/liter of items in a special timeframe, but I get the error: <code>column return must be in group by</code></p>
  
  <p>After I add that column: <code>cannot group by aggregate column</code>.</p>
  
  <p>This is functional, just without the timeframe:</p>
  
  <pre><code>CASE WHEN 
      SUM(vkdtab.amount*liter)&lt;&gt;0
  THEN SUM(net)/SUM(vkdtab.amount*liter) 
  ELSE 0 END
  </code></pre>
  
  <p>How can I add the timeframe without getting an error?</p>