Question: Not sure if this is possible to do using SQL. Any type of database server is okay to use to test it.

I have a table called category which looks like this below,

```
  Gender  |  Age
 -----------------
    M     |   25
    M     |   36
    F     |   22
    M     |   54
    F     |   28
    F     |   41

```

When I use,  

`SELECT GENDER * FROM CATEGORY`   

```
   Gender     
    M        
    M        
    F        
    M        
    F  
    F

```

I am wondering if there is a way to do any kind of modification with the data in the table when we pull the column without making any change with the data in the existing table.

I want something like this below,

```
    Gender     
    Male        
    Male        
    Female        
    Male        
    Female  
    Female

```

I do not want to change the data in the table. Is there a way, I can add something to the SELECT query to get the above details from my table?

Answer: 
As @GordonLinoff suggested in the comments:

```
SELECT CASE WHEN Gender='M' THEN 'Male' WHEN Gender='F' THEN 'Female' END as Gender
FROM Category;

```
`CASE` expressions, as suggested in other answers, are an OK solution if you really need to do this by hand.

The much better solution is to have a lookup table in your database, and to do a join. Something like this:

```
create table gender_codes ( gender_code, gender_name ) as 
  select 'M', 'Male'   from dual union all
  select 'F', 'Female' from dual
;

```

This creates a very small table in your database.

Then:

```
select gc.gender_name
from   category     c
       join 
       gender_codes gc on c.gender = gc.gender_code
;

```

This can be mimicked with a WITH clause:

```
with gender_codes as (
       select 'M' as gender_code, 'Male'   as gender_name from dual union all
       select 'F'               , 'Female'                from dual
     )
select gc.gender_name
from   category     c
       join 
       gender_codes gc on c.gender = gc.gender_code
;

```

but this solution isn't much different from the `case` solutions.

The benefit of the small table is that you don't have to re-write the lookup code every time you write a new query. It also avoids accidental misspellings like `'Femlae'` - and if later you need to add more codes and more genders, it will be exceptionally easy to do with the lookup table, and a pain in the butt to do with hardcoded `WITH` clause or `CASE` expressions.