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;
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;
相关文章推荐
- Oracle 11G函数整理(编码解码函数)
- Oracle 11G函数整理(日期函数)
- Oracle 11G函数整理(转换函数)
- Oracle 11G函数整理(字符函数)
- Oracle 11G函数整理(环境标识函数)
- Oracle 11G函数整理(数值函数)
- Oracle 11G函数整理(聚合函数)
- Oracle 11G函数整理(一般比较函数)
- Oracle 11G函数整理(层次函数)
- Oracle 11G函数整理(聚合函数)
- Oracle 10g/11g 导入导出整理
- Oracle 11g学习笔记--分析函数
- oracle 函数整理(一)
- ORACLE TRUNC()函数整理
- Oracle 分析函数(11G)语法详解(转)
- [总结]oracle 11g新函数全攻略
- ORACLE升级11g以上之前版本的wm_concat()函数失效
- oracle笔记整理6——常见函数、scott解锁、length与lengthb、char与varchar
- oracle 11g 函数集合
- ORACLE函数整理(函数暂不分类,以编程过程中遇到的先后添加)