表person记录
查询语句:
select name,
(case
when sex='男' then 1
when sex='女' then 0
else 2 end
) as sexcode
from person
查询结果:
表person记录
查询语句:
select name,
(case
when sex='男' then 1
when sex='女' then 0
else 2 end
) as sexcode
from person
查询结果: