Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Calculate with Null
Sun, Jan 17 2010 1:09 PMPermanent Link

"Sorin H"
Hello

I want to run this sql when all the fields are integers.
"select col1, col2, (col1+col1)"

and when col1 or col2 are Null the calculated field will refer to the Null
fiedls as zero.

I try Coalesce and Cast but the calculation remain the same.

Any suggestions?
Thanks Sorin

Sun, Jan 17 2010 1:51 PMPermanent Link

Uli Becker
Sorin,

> and when col1 or col2 are Null the calculated field will refer to the Null
> fiedls as zero.
>
> I try Coalesce and Cast but the calculation remain the same.

This works:

select col1, col2, coalesce(col1,0) + coalesce(col2,0) as sum from MyTable;

Regards Uli
Image