Here is the code to use the Case statment in Sql Server
create table myTable(ID int identity, Name varchar(50), Sex int) insert into myTable(Name, Sex) values ('Meenakshi', 0) insert into myTable(Name, Sex) values ('Mohit Sharma', 1) insert into myTable(Name, Sex) values ('Sanjay Bamal', 1) insert into myTable(Name, Sex) values ('Munni Bai', 2) insert into myTable(Name, Sex) values ('hihihihi', 9)
select myTable, case Sex when 0 then 'female' when 1 then 'male' when 2 then 'unknown' else 'Invalid Sex' end as "Sex" from patients
Here is the output from this T-SQL code:
Name Sex ------------------ ------------------------ Meenakshi female Manoj Sharma male Sanjay Bamal male Munni Bai unknown hihihihi Invalid Sex
|
No responses found. Be the first to respond and make money from revenue sharing program.
|