Daredevil
Daredevil

Reputation: 41

Replace values in the result set using a select query

How to replace the values 1 and 2 by "Male" and "Female" respectively in a table while selecting using single select query?

Name     Gender
a         1
a         2

Upvotes: 1

Views: 4769

Answers (1)

Andomar
Andomar

Reputation: 238086

select  Name
,       case Gender
        when 1 then 'Male'
        when 2 then 'Female'
        end as Gender
from    YourTable

Upvotes: 7

Related Questions