您的位置:首页 > 数据库 > Oracle

Oracle 11G函数整理(NULL值处理函数)

2013-09-30 18:04 411 查看
1、COALESCE(expr1,expr2……) 如果第一个为NULL就判断第二个,如果第二个为NULL判断第三个,直到最后一个

selectCOALESCE(null,1) a1,COALESCE(null,null,1) a2,COALESCE(null,null) a3 from dual;

2、LNNVL(condtion)

Condition=false——>true

Condition=true——>false

Condition 结果未知——>true

selectempno,ename from scott.emp where LNNVL(DEPTNO=0);

3、NANVL(n1,n2) 如果n1是数字就返回n1,否则返回n2

selectNANVL(1.24,2) a1,NANVL(deptno,2) a2 from scott.emp;

4、NULLIF(expr1,expr2) 如果expr1=expr2返回null,否则返回expr1

selectNULLIF(1,1) a1,NULLIF(1,2) a2 from dual;

5、NVL(expr1,expr2) 如果expr1为NULL则返回expr2,否则返回expr1

selectNVL(NULL,'A') a1,NVL(1,2) a2from dual;

6、NVL2(expr1,expr2,expr3)如果expr1不为NULL返回expr2,否则返回expr3

select NVL2(NULL,'A','B')a1,NVL2(NULL,NULL,'Hello')a2,NVL2('A',NULL,'Hello')
a3,NVL2('A','A','Hello')
a4 from dual;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: