title: SQL SUM, Group by and Having query
body: <p>I have a pretty standard query that will get me a list of products that have stock above 0.</p>
  
  <p>This works fine, however I now need to ADD the SUM of all negative numbers for BranchID 31 for the given SKU. </p>
  
  <pre><code>SELECT * FROM Products WHERE
  PrimaryPLU IN 
  (select SKU FROM Stock 
  WHERE BranchID IN (2,12,1,11,0,96,32,13,14,15) 
  AND ApplicationID = @site 
  GROUP BY SKU HAVING(SUM(Stock)) &gt; 0))
  </code></pre>
  
  <p>SO BranchID 31 can have positive and negative numbers, however I just need to get the sum of the negative ones for the SKU, this then needs to be added to the check to see if it's over 0.</p>
  
  <p>Not a clue where to start, was hoping for support from a SQL master!</p>
  
  <p>Thanks in advance!</p>
  
  <p>Dave</p>