Reputation: 325
I have a table named user. In this table, there is a column named 'Sex', which has value 'm'
or 'f'
. I want to present these values as 'male'
or 'female'
without changing the exact value in the database. What is the best way?
Upvotes: 0
Views: 1213
Reputation: 14928
Using a CASE
expression since you have only 'm'
and 'f'
SELECT
Sex,
CASE Sex WHEN 'm' THEN 'male'
else 'female' END AS SexLabel
FROM yourTable;
Upvotes: 0
Reputation: 521289
Use a CASE
expression:
SELECT
Sex,
CASE Sex WHEN 'm' THEN 'male'
WHEN 'f' THEN 'female' END AS SexLabel
FROM yourTable;
Upvotes: 5