title: Proper syntax when SUM case when statement is formatted
body: <p>I am trying to sum two different values in my database. </p>
  
  <p><code>Species</code> can either be 12 or 14. I have removed the rest in my select statement.</p>
  
  <p>I want to do a total or <code>SUM</code> for all rows that have a species value of 12, and the same when the species has a value of 14.</p>
  
  <p>I don't understand how to format the syntax. This is my query: </p>
  
  <pre><code>SELECT h.HarvestDate, c.LotNo, h.Producer, c.species
      SUM CASE WHEN c.Species = 12 THEN LambYT ELSE 0 as LambYT
      SUM CASE WHEN c.Species = 14 THEN LambYTSpoolJoint ELSE 0 as LambYTSpoolJoint
  FROM BANSS.dbo.DixonCarcass_InProcess c, BANSS.dbo.HarvestData_SFDCApp h
  WHERE c.LotNo = h.Lot
      AND c.Species in (12, 14)
      AND h.Program not LIKE 'K&amp;R%'
  GROUP BY h.HarvestDate, c.LotNo, h.Producer
  </code></pre>
  
  <p>However I believe this is incorrect. I would like a <code>SUM</code> where <code>Species = 12</code> and a sum where <code>Species = 14</code> and a total of the two sums as <code>TOTAL</code>.</p>