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 |
|
sasan_vm
Yak Posting Veteran
51 Posts |
Posted - 2009-02-21 : 10:00:21
|
| Hello, in this query:SELECT SUM(Amount) AS RecivedFROM dbo.tbl_balanceWHERE (Amount > 0)if no record see condition (Amount > 0) then Recived set to NULL,how can change this query in this status Recived set to zero.Kind Regards,sasan. |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2009-02-21 : 10:25:48
|
I am guessing that what you want is this:SELECT coalesce(SUM(Amount),0) AS RecivedFROM dbo.tbl_balanceWHERE (Amount > 0) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-22 : 01:00:47
|
| [code]SELECT SUM(CASE WHEN Amount > 0 THEN Amount ELSE 0 END) AS RecivedFROM dbo.tbl_balance[/code] |
 |
|
|
krij
Starting Member
9 Posts |
Posted - 2009-02-23 : 04:01:53
|
| SELECT SUM(Isnull(Amount,0)) AS RecivedFROM dbo.tbl_balanceWHERE (Amount > 0) |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-23 : 05:47:34
|
quote: Originally posted by krij SELECT SUM(Isnull(Amount,0)) AS RecivedFROM dbo.tbl_balanceWHERE (Amount > 0)
This won't give you expected result. |
 |
|
|
|
|
|