title: Using MySQL alias name with case statement after then
body: <p>I can't use MySQL alias name with CASE statement, it give syntax error as following:</p>
  
  <pre><code>SELECT IFNULL(min(mFR.date),'') AS `firstDate`,
      CASE `data` 
          WHEN 'Sales'         THEN IFNULL(SUM(qty),0) AS `sales`
          WHEN 'Return'        THEN IFNULL(SUM(qty),0) AS `return`
          WHEN 'Receiving In'  THEN IFNULL(SUM(qty),0) AS `receiving_in`
          WHEN 'Receiving Out' THEN IFNULL(SUM(qty),0) AS `receiving_out`
          WHEN 'Stock'         THEN IFNULL(SUM(qty),0) AS `stock`
      END
  FROM  `full_report`
  </code></pre>
  
  <p>It gives me (syntax error near [AS <code>sales</code>]).</p>
  
  <p>Any suggestions?</p>