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 2000 Forums
 SQL Server Development (2000)
 select sum() returns null

Author  Topic 

caisys
Starting Member

16 Posts

Posted - 2004-01-21 : 08:53:06
hi,

i have the following query to sum the total due balance for a customer:

select sum(outstanding)from out where customer = 'myvariable' the problem is when the customer has no outstanding it returns NULL is there a way to return 0 when there are no outstanding?

thanks

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-01-21 : 09:05:30
Have a look at ISNULL in BOL
Go to Top of Page

raymondpeacock
Constraint Violating Yak Guru

367 Posts

Posted - 2004-01-21 : 09:11:33
Try

SELECT ISNULL(SUM(outstanding), 0)
FROM out
WHERE customer = 'myvariable'



Raymond
Go to Top of Page
   

- Advertisement -