Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 summation based on some condition

Author  Topic 

vivo
Starting Member

24 Posts

Posted - 2010-05-31 : 00:26:41
I have the normal statement to get the summation
sum(colA ) where ... .
Now I want to do summation based on some condition as below

if (status ="s1' or status="s2") and (colA > colB)
sum(colA - colB)

else
sum(colA)

Can anyone help ? tks.

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2010-05-31 : 01:16:05
use case statement.........
Go to Top of Page
   

- Advertisement -