title: sum 2 columns based on different criteria in the same table
body: <p>I am on SQL Server 2012 and have a table that looks similar to below:</p>
  
  <p>Table <code>Trans</code>:</p>
  
  <pre><code>Amount   Itype     hPlant     PostDate
  22.45     2         dplf      01/01/2016
  45.55     2         dplf      01/01/2016
  965.32    4         dplf      02/01/2016
  14.25     3         dplf      01/01/2016
  72.36     3         esch      01/01/2016
  114147.77 2         dplf      01/01/2016
  9641.25   4         dplf      01/01/2016
  300.00    2         dplf      02/01/2016
  </code></pre>
  
  <p>I need to select the sum of amount with an <code>itype=2</code> and <code>date=01/01/2016</code> and the sum of amount with <code>itype=3</code> and <code>date=01/01/2016</code> and <code>plant=dplf</code> plus some other data from various other tables.</p>
  
  <p>How do I select the sums on 2 different criteria from one table. I have something similar to this:</p>
  
  <pre><code>SELECT 
      SUM(tr.amount), SUM(tr2.amount),
      CONVERT(VARCHAR, tr.date, 1) + ' ' + 'TB  Upload' Reference,
      p.scode 
  FROM 
      trans tr 
  INNER JOIN 
      plant p on p.hmy = tr.hplant
  INNER JOIN  
      trans tr2 on tr2.hplant = tr.hplant 
  WHERE 
      tr.date = '01/01/2016' 
      AND tr.itype = 2 
      AND tr2.itype = 3 
      AND tr2.date = '01/01/2016'
  GROUP BY  
      tr.date, p.scode
  </code></pre>
  
  <p>My results are not the same as if I ran them individually. Please help!</p>