Saturday, February 25, 2012

Convert Null Values to 0

Hi

I've got a view which returns Null values due to an left outer join. The field which sometimes returns Nulls is called ClientCount. I want to create a new field which displays the value of ClientCount if ClientCount is not null and 0 if it is null.

In MS Access I use the following: IIF([ClientCount] Is Null,0,[ClientCount])

This does not seem to work in MS SQL. Is there some equivalent function I could use?

Thanks

David

David:

The best way to convert a null to a zero is to use ISNULL( [Client Count], 0 ) or COALESCE( [Client Count], 0 ).

|||How to convert null to zero ina query.

No comments:

Post a Comment