在oracle查询中查询出具体的数值,让它显示具体的其他的数值,类似if语句的用法。
查询test表,如果sex列查询出来值是1,就显示‘男’,如果查询出来值是0,就显示‘女’,都不是就显示‘其他’
1. decode函数实现方法:
select decode(sex,1,'男',0,'女','其他') as id test ;
2. case when 实现方法:
select case sex
when 1 then '男'
when 0 then '女'
else '其他' end
from test ;