–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