title: Sum of calculated field
body: <p>I have two tables:  </p>
  
  <ul>
  <li>table1 (a,b,c)  </li>
  <li>table2 (a,d,f)  </li>
  </ul>
  
  <p>I want to get for each b to get sum of multiplication of corresponding d and f  </p>
  
  <h3>table 1 data</h3>
  
  <pre><code>a   b      c
  -------------
  1   hello  3
  2   bye    4
  </code></pre>
  
  <h3>table 2 data</h3>
  
  <pre><code>a  d  f
  --------
  1  5  3
  1  2  4
  2  1  3
  2  2  3
  </code></pre>
  
  <p>result: hello:5*3+2*4  , bye:1*3+2*3<br>
  My query is:   </p>
  
  <pre><code>  SELECT t1.a, 
           t2.d * t2.f AS m, 
           SUM(m)   
      FROM table1 AS t1, 
           table2 AS t2 
     WHERE t1.a = t2.a 
  GROUP BY t1.b
  </code></pre>
  
  <p>So what is wrong here?  In mysql I get #1054 - Unknown column 'm' in 'field list'</p>