Thursday, 20 June 2013

how to get sum of positive and negative numbers

Hi, I have table which containse positive and negative numbers
 I need sum of positive and negative numbers
 create table #esal(esal int)

insert into #esal values(-2)
insert into #esal values(-3)
insert into #esal values(12)
insert into #esal values(23)
 --select * from #esal


 select SUM(esal) from #esal group by case when esal>0 then '+ve' else '-ve' end

Monday, 15 April 2013

Source Result set
---------------
Source Result set

Destination result set
-----------------------

Destination Result set