title: How to minus instead of add in a Sum() like sql function
body: <p>I have a group by clause in a sql statement and need to use an aggregate function to minus all the values in each group instead of adding like the Sum() function.</p>
  
  <p>i.e.  </p>
  
  <pre><code>SELECT Sum(A) 
  FROM (  
    SELECT 2 AS A
    UNION 
    SELECT 1) AS t1
  </code></pre>
  
  <p>..so will evaluate 2+1 and return 3.</p>
  
  <p>I need some way of doing 2-1 to return 1.</p>
  
  <p>Hope this makes sense.  Only way I can think of doing this would be to use CLR integration to make my own aggregate function.</p>
  
  <p>Any other ideas?</p>