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.
| 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 - valuesSELECT 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 |
 |
|
|
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 |
 |
|
|
rjhe25
Starting Member
21 Posts |
Posted - 2009-04-14 : 10:41:47
|
| thats great thanks very much |
 |
|
|
|
|
|