title: How to SUM and SUBTRACT using SQL?
body: <p>I am using MySQL and I have two tables:</p>
  
  <p><code>master_table</code></p>
  
  <ul>
  <li>ORDERNO </li>
  <li>ITEM</li>
  <li>QTY</li>
  </ul>
  
  <p><code>stock_bal</code> </p>
  
  <ul>
  <li>ITEM </li>
  <li>BAL_QTY</li>
  </ul>
  
  <p>Master table has duplicate <code>ORDERNO</code> and <code>ITEM</code> values. I have get total <code>QTY</code> using SQL 'GROUP BY' clause.</p>
  
  <p>I need to deduct/subtract <code>BAL_QTY</code> from SUM of <code>ITEM</code> (master_table).  I've got SUM <code>QTY</code> value using query (actually there are many rows).</p>