DECODE()函数
DECODE(value, if1, then1, if2,then2, if3,then3, . . . else )
含义解释:
DECODE(条件,值1,翻译值1,值2,翻译值2,...值n,翻译值n,缺省值)-- 该函数的含义如下:IF 条件=值1 THENRETURN(翻译值1)ELSIF 条件=值2 THENRETURN(翻译值2)......ELSIF 条件=值n THENRETURN(翻译值n)ELSERETURN(缺省值)END IF
DECODE 的简单例子
select sid,serial#,username, DECODE(command, 0, 'None', 2, 'Insert', 3, 'Select', 6, 'Update', 7, 'Delete', 8, 'Drop', 'Other') cmmand from v$session where username is not null;
select decode(3, 1,'yi', 2,'er') from dual;