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
 adding the columns

Author  Topic 

sqldev6363
Yak Posting Veteran

54 Posts

Posted - 2011-06-02 : 12:46:58
This is the table with values i have

Col1 Col2 Col3
1.2 NULL 3.54
2.34 NULL 1.23
3.35 NULL 34.000

When i tried this select (col1+col2+col3) as Total from table i am getting the result with null values

I need the result set with numbers and have to ignore NULLS while adding

Total
3.74
3.57
37.35

i need the result this like this...can any one help me out in this

all columns are decimal data type

dev

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-06-02 : 12:50:06
Add it like this:

isnull(col1,0) + isnull(col2,0) + isnull(col3,0)
Go to Top of Page
   

- Advertisement -