Three way to replace null values :
ISNULL : if gender value is null it is replace with other
ID Name Gender Salary Mng_id.
1 Tom M 4000 1
2 Prema F 5000 3
3 sam Null 3000 4
4 James F 500 2
select isnull (Gender , 'Other') from tbl_emp
CASE :
ID F_Name M_Name Salary Mng_id.
1 Tom Null 4000 1
2 Prema Todda 5000 3
3 sam Null 3000 4
4 James Parker 500 2
Example:
Select CASE when M_Name=NULL then 'No_Name'
ELSE M_Name END as M_Name from tbl_Emp ;
COALESCE FUNCATION IN SQL SERVER
ID F_Name M_Name Salary Mng_id.
1 Tom Null 4000 1
2 Prema Todda 5000 3
3 sam Null 3000 4
4 James Parker 500 2
example:
select ID , COALESCE ( F_Name,M_Name) as Name
from tbl_emp
No comments:
Post a Comment