如何使用oracle的decode函数进行多值判断
1个回答
展开全部
Decode函数的语法结构如下:
decode (exPRession, search_1, result_1)decode (expression, search_1, result_1, search_2, result_2)decode (expression, search_1, result_1, search_2, result_2, ...., search_n, result_n)decode (expression, search_1, result_1, default)decode (expression, search_1, result_1, search_2, result_2, default)decode (expression, search_1, result_1, search_2, result_2, ...., search_n, result_n, default)
decode函数比较表达式和搜索字,如果匹配,仔谈嫌返回结果;如果不匹配,返回default值;如念手果未定义default值,则返侍歼回空值。
以下是一个简单测试,用于说明Decode函数的用法: SQL> create table t as select username,default_tablespace,lock_date from dba_users;Table createdSQL> select * from t;USERNAME DEFAULT_TABLESPACE LOCK_DATE
------------------------------ ------------------------------ -----------SYS SYSTEMSYSTEM SYSTEM
DBSNMP SYSTEM
SCOTT SYSTEM
------------------------------ ------------------------------ -----------
------------------------------ --------
SYS unlocked
SYSTEM unlocked
DBSNMP unlocked
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询