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 |
|
ninel
Posting Yak Master
141 Posts |
Posted - 2005-07-07 : 11:57:49
|
| I have 3 columns that need to be summed up, but any one of these can contain a NULL value.Col1 Col2 Col3 Col4A 2.67 4.7 2.8B 6.2 NULL 2.6C 12.4 NULL NULLHow can I sum them up to look like this without updating the NULLS with a 0?A = 10.17B = 8.8C = 12.4Thanks,Ninel |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-07-07 : 12:11:08
|
| Lookup COALESCE in books on-line.- Jeff |
 |
|
|
CokoBWare
Starting Member
6 Posts |
Posted - 2005-07-08 : 09:57:14
|
| Try wrapping the Col2, Col3, and Col4 in ISNULL...so, A = ISNULL(Col2,0) + ISNULL(Col3,0) + ISNULL(Col4,0)ISNULL is really handy when you need to check for NULL and substitute without actually changing your table. |
 |
|
|
|
|
|