title: Sum of single column for different conditions
body: <p>I have two columns in my table <strong>colum#1</strong> is <code>varchar(MAX)</code> and column#2 is <code>int</code>.</p>
  
  <p>In <strong>column#2</strong> I have negative and positive entries I want sum of positive entries in one column and sum of negative entries in other column in my select query </p>
  
  <p>To achieve this I did</p>
  
  <pre><code>SELECT SUM(atbl.M),SUM(atbl.p)    
  from (select M=case when column#2&lt;0 
                      then column#2 else 0 end,
               P=case when column#2 &gt; 0 
                      then column#2 else 0 end 
          from testTable) atbl
  </code></pre>
  
  <p>or</p>
  
  <pre><code>select SUM(case when column#2&lt;0 then column#2 else 0 end) as M
        ,SUM(case when column#2 &gt; 0 then column#2 else 0 end) as P 
   from testTable
  </code></pre>
  
  <p>Is there any better way to achieve this.</p>