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
 General SQL Server Forums
 New to SQL Server Programming
 minus values

Author  Topic 

rjhe25
Starting Member

21 Posts

Posted - 2009-04-14 : 10:23:21
hi i have a query to do on a cash balance table. they want they total amount. but i have to leave out - values . this is what i have done so far to sum the total any one have any idea how i would leave out the - values

SELECT SUM(Balance)
FROM dbo.Cash_Balances

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-04-14 : 10:33:42
SELECT SUM(Balance)
FROM dbo.Cash_Balances WHERE Balance > 0
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-04-14 : 10:34:46
select sum(case when Balance < 0 then 0 else Balance end)
from dbo.Cash_Balances
Go to Top of Page

rjhe25
Starting Member

21 Posts

Posted - 2009-04-14 : 10:41:47
thats great thanks very much
Go to Top of Page
   

- Advertisement -