当前位置: 移动技术网 > IT编程>数据库>Oracle > Oracle 中 decode 函数用法(字段A,B, C,A不为空则取A,否则取B,B为空则取C)

Oracle 中 decode 函数用法(字段A,B, C,A不为空则取A,否则取B,B为空则取C)

2019年05月23日  | 移动技术网IT编程  | 我要评论

吴晓丹的老公,鸿泰影城影讯,俄女主持竞选总统

–decode(条件,值1,返回值1,值2,返回值2,…值n,返回值n,缺省值)
select decode(temp.score,
‘a’,
‘90-100’,
‘b’,
‘80-89’,
‘c’,
‘70-79’,
‘d’,
‘60-69’,
‘e’,
‘0-59’,
‘其他’) as xxx
from (select ‘a’ score from dual) temp
–结果:’90-100’

–decode(条件,比较值,值1,值2)
–当条件的值等于比较值时,该函数返回值1,否则返回值2
select decode(null,
temp.a,
decode(null, temp.b, decode(null, temp.c, ”, temp.c), temp.b),
temp.a) as xxx
from (select null a, ‘b’ b, ‘c’ c from dual) temp

select decode(temp.a,
null,
decode(temp.b, null, decode(temp.c, null, ”, temp.c), temp.b),
temp.a) as xxx
from (select null a, null b, ‘c’ c from dual) temp

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网