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
 Case Statement

Author  Topic 

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2009-01-24 : 05:37:22
I am trying to use a case statement in SQL 2005 in computing AR_Balance. One of my tables houses payments which can be null. I want to say if tblPayments.pAmount is null make the value a 0 and subtract tblBilling.bAmount from tblPayments.pAmount. I cannot get a case statement to work though. Can anyone help me with this? Is this appropriate use of a case statement?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-24 : 05:53:11
COALESCE(pAmount, 0)



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-24 : 08:38:14
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/10/04/isnull-or-coalesce.aspx
Go to Top of Page
   

- Advertisement -