title: Can I reuse a calculated field in a SELECT query?
body: <p>Is there a way to reuse a calculated field within a mysql statement. I get the error "unknown column total_sale" for:</p>
  
  <pre><code>SELECT 
      s.f1 + s.f2 as total_sale, 
      s.f1 / total_sale as f1_percent
  FROM sales s
  </code></pre>
  
  <p>or do I have to repeat the calculation, which would make for a very long SQL statement if I added all the calculations I need.</p>
  
  <pre><code>SELECT 
      s.f1 + s.f2 as total_sale, 
      s.f1 / (s.f1 + s.f2) as f1_percent
  FROM sales s
  </code></pre>
  
  <p>of course I can do all the calculations in my php program.</p>