title: Special Group by & SUM
body: <p>I have a table with the following fields:
  <code>ID, S, W</code> and data Like:</p>
  
  <pre><code>1,s1,w1
  1,s2,w1
  1,s3,w2
  2,s4,w2
  </code></pre>
  
  <p>I would like to calculate SUM of S for each Id only for W = w1 and zero as result for other ID that don't have any data for w1.  for this example I have to get </p>
  
  <pre><code>1, s1+s2, w1
  2, 0, null or 0
  </code></pre>
  
  <p>which means if Id has w1 show only this some,but if Id=2 has only W different of w1 show it as well. 
  I tried</p>
  
  <p><code>SUM(CASE W = w1 THEN S ELSE 0 END) AS S GROUP BY ID, W</code>
  but don't how to show also W? I hope i was clear is part of a UDF with a lot of other tables involved.  Any help would be greatly appreciated.</p>