Re: NULL encountered in math
- From: "David Portas" <REMOVE_BEFORE_REPLYING_dportas@xxxxxxx>
- Date: Tue, 1 Nov 2005 21:08:14 -0000
"Joseph" <Joseph@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:674BC95B-D16C-42B2-ACEA-7F8D799DD38E@xxxxxxxxxxxxxxxx
>I need to subtract two values in a table. One of these values contains a
> NULL entry. Each time I use the (Pledge - Credit) as 'Difference' I get
> the
> value of NULL.
>
> How do I get T-SQL to replace the NULL with zero?
>
> I encountered this a long time ago while concatenating data. I was able
> to
> use the command SET CONCAT_NULL_YIELDS_NULL OFF for strings. But I can't
> find anything for numbers.
>
> Thanks in advance
You can use COALESCE or ISNULL. Example:
COALESCE(pledge,0) - COALESCE(credit,0) AS difference
--
David Portas
SQL Server MVP
--
.
- Next by Date: Re: Compare Character to numberic
- Next by thread: Re: Compare Character to numberic
- Index(es):