March 13, 2008 at 6:55 am
Hi,
I have a table there are three columns:
1. Id_Pk
2. Emp_Name
3. Salary
Some Salary fields have Null, Now i want to select table data in such a way that where salary is null there should show '0'. I want result only in one query.
Tell me abt this problem.
Regards
Sarvesh kumar gupta
March 13, 2008 at 7:04 am
Sarvesh Kumar Gupta (3/13/2008)
Hi,I have a table there are three columns:
1. Id_Pk
2. Emp_Name
3. Salary
Some Salary fields have Null, Now i want to select table data in such a way that where salary is null there should show '0'. I want result only in one query.
Tell me abt this problem.
Regards
Sarvesh kumar gupta
select
Id_Pk,
Emp_Name,
coalesce(Salary, 0) as Salary
from
dbo.MySalaryTable
March 13, 2008 at 7:15 am
Hi,
Thanx, This is working right. what do you tell me abt coalesce().
Sarvesh:)
March 13, 2008 at 7:23 am
Read BOL (Books Online), it will provide you all the info you are asking.
😎
December 31, 2009 at 2:23 am
coalesce: This function checks all the columns specified in the function and returns the column value which is not null. Simply we can say Returns the first nonnull expression among its arguments
December 31, 2009 at 2:34 am
select Id_Pk,Emp_Name,isnull(Salary, 0) as Salary from dbo.MySalaryTable
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply