title: SQL Server : SUM Values and find the difference from two different tables
body: <p>I have the following two tables and I want to find the difference between table 1 and table 2 for the month of "January". The difference should be the sum of all values for January in table 1 minus the sum of all values for the month of January in table 2.</p>
  
  <p>The answer should be 300 (800 - 500), but my query keeps giving me the value "600".</p>
  
  <p>My query is:</p>
  
  <pre><code>SELECT 
      a.month,
      (SUM(a.cost2)) - (SUM(b.cost2)) AS difference
  FROM 
      Table1 a
  LEFT JOIN 
      Table2 b ON a.Month = b.Month
  WHERE 
      a.month = 'January'
  GROUP BY 
      a.month
  </code></pre>
  
  <p>Table 1</p>
  
  <pre><code>Month    Cost2
  --------------
  January  500
  February 400
  March    300
  April    600
  January  300
  March    200
  March    400
  April    200
  </code></pre>
  
  <p>Table 2</p>
  
  <pre><code>Month    Cost2
  --------------
  January  200
  February 250
  March    195
  April    700
  January  300
  February 200
  March    400
  April    200
  </code></pre>