using CASE (Transact-SQL)

Syedshakeer
Posted by Syedshakeer under Sql Server category on | Views : 2405
Write a Query to dispaly the data from a Table when 'M' as 'MALE' and 'F' as 'FEMALE ?

ID Name Gender

1 AAA M
2 BBB F
3 CCC F

Ans)
select name,
Gender=case Gender when 'M' then 'MALE'
when 'F' then 'FEMALE'
end
from table_name

OutPut:-


Name Gender

AAA MALE
BBB FEMALE
CCC FEMALE

Comments or Responses

Login to post response