title: Mysql Group By condition
body: <p>I want to Apply condition for <code>GROUP BY</code>.</p>
  
  <p>When the condition <code>city_id != 0</code> is true, group the list. Otherwise normal list.</p>
  
  <p>I used this query for that:</p>
  
  <pre><code>(
      SELECT city_id, sum(sales) as counts
      FROM product_sales
      WHERE city_id !=0     
      GROUP BY city_id
  )
  UNION
  (
      SELECT city_id, sales 
      FROM product_sales  
      WHERE city_id =0     
      ORDER BY sales_id 
  )
  </code></pre>
  
  <p>Anyone can help me avoid the <code>UNION</code> and get the list in a single query?</p>