title: update query issue of GROUP BY sum() function in mysql
body: <p>Here is the <a href="http://sqlfiddle.com/#!2/0648c/1" rel="nofollow">sqlfiddle link</a> <br/>
  I am trying to use <code>sum()</code> function. It's working only <code>SELECT</code> query but it's give wrong value when I try this in subquery on <code>UPDATE</code> query.Here my <code>SELECT</code> query</p>
  
  <pre><code>SELECT 
    sum(i.pr_pur_cost_price*i.quantity) AS net_amount
  FROM 
    product_purchases AS p
  LEFT JOIN 
    product_purchase_item AS i
  ON 
    p.product_purchase_item_id=i.product_purchase_item_id
  WHERE 
    p.insert_operation=48
  GROUP BY 
    p.insert_operation
  </code></pre>
  
  <p>Here My update query</p>
  
  <pre><code>UPDATE 
    shop_balance AS s 
  SET 
     s.shop_balance=(s.shop_balance-(
        SELECT 
           sum(i.pr_pur_cost_price*i.quantity) as net_amount 
        FROM 
           product_purchases AS p
        LEFT JOIN 
           product_purchase_item AS i
        ON
           p.product_purchase_item_id=i.product_purchase_item_id
        WHERE 
           p.insert_operation=48
        GROUP BY 
           p.insert_operation
       )
     )
  where s.shop_balance_id=n;    
  </code></pre>
  
  <p>Why this wrong value in UPDATE query. is it problem for two columns in sum() function? or any best solution?</p>