How to Convert Null Value To Number In SQL Server

Do you know, or you can calculate Null value in SQL Server or not?
when you select some data from table of database, sometime you get
null value. but you want to use this value for calculate to other values.
The solution, you must convert null value to numeric value when your
data is null value.

Please see this function and example:

1. Function is COALESCE(Field,Numeric Value)
2. Example:
Select Age From tbl_Employee Where Age between 25 and 35
Result=Null
So you can use code below:

Select COALESCE(Age,0) From tbl_Employee Where Age between 25 and 35
There are a lot of data,

this code is when have null value it change to 0

No comments:

Post a Comment