title: SUM(a*b) not working
body: <p>I have a PHP page running in postgres. I have 3 tables - <em>workorders</em>, <em>wo_parts</em> and <em>part2vendor</em>. I am trying to multiply 2 table column row datas together, ie <em>wo_parts</em> has a field called <em>qty</em> and <em>part2vendor</em> has a field called <em>cost</em>. These 2 are joined by <em>wo_parts.pn</em> and <em>part2vendor.pn</em>. I have created a query like this:</p>
  
  <pre><code>$scoreCostQuery = "SELECT SUM(part2vendor.cost*wo_parts.qty) as total_score 
                         FROM part2vendor 
                         INNER JOIN wo_parts 
                           ON (wo_parts.pn=part2vendor.pn)  
                         WHERE workorder=$workorder";
  </code></pre>
  
  <p>But if I add the costs of the parts multiplied by the qauntities supplied, it adds to a different number than what the script is doing. Help....I am new to this but if someone can show me in SQL I can modify it for postgres. Thanks</p>