title: Impala error: AnalysisException: select list expression not produced by aggregation output (missing from GROUP BY clause?):
body: <p>This is my first post. hope i'll be clear :)</p>
  
  <p>I try to run on impala (using Hue) the next query in 2 version.</p>
  
  <p><strong>Version 1 (group by 1):</strong></p>
  
  <pre><code>SELECT payment_method,
         (CASE WHEN price &lt;= 1000 AND country = 'israel' THEN  (price+50+0.18*price)/count(Distinct payment_token)/100
              WHEN price &lt;= 1000 AND country &lt;&gt; 'israel' THEN (price+50)/count(Distinct payment_token)/100
              WHEN price &gt; 1000  AND country = 'israel' THEN (price+0.05*price+0.18*price)/100
              ELSE (price+0.05*price)/count(Distinct payment_token)/100
          END) as ASP
  FROM traffic_db.traffic_parq
  WHERE year = 2016 AND month = 1
  Group by 1
  
  Error 1: AnalysisException: select list expression not produced by aggregation output (missing from GROUP BY clause?): CASE WHEN price... (rest of case when statment)
  </code></pre>
  
  <p><strong>Version 2 (group by 1,2):</strong></p>
  
  <pre><code>SELECT payment_method,
         (CASE WHEN price &lt;= 1000 AND country = 'israel' THEN  (price+50+0.18*price)/count(Distinct payment_token)/100
              WHEN price &lt;= 1000 AND country &lt;&gt; 'israel' THEN (price+50)/count(Distinct payment_token)/100
              WHEN price &gt; 1000  AND country = 'israel' THEN (price+0.05*price+0.18*price)/100
              ELSE (price+0.05*price)/count(Distinct payment_token)/100
          END) as ASP
  FROM traffic_db.traffic_parq
  WHERE year = 2016 AND month = 1
  Group by 1,2
  
  Error: AnalysisException: GROUP BY expression must not contain aggregate functions: 2
  </code></pre>
  
  <p>I don't know what happen to be the problem.
  NOTE: If i run a <code>CASE-WHEN</code> statement with non-calculated values - it works fine (when i group by also by the case-when statement).</p>
  
  <p>Has someone encountered this sort of a problem? </p>