oracle中nvl函数在mysql里面怎么使用
来源:互联网 发布:烯牛数据工作怎么样 编辑:程序博客网 时间:2024/06/04 20:04
Oracle中的NVL函数
Oracle中函数以前介绍的字符串处理,日期函数,数学函数,以及转换函数等等,还有一类函数是通用函数。主要有:NVL,NVL2,NULLIF,COALESCE,这几个函数用在各个类型上都可以。
下面只介绍介绍nvl函数的用法。
在介绍这个之前你必须明白什么是oracle中的空值null
NVL函数
NVL函数的格式如下:NVL(expr1,expr2)
含义是:如果oracle第一个参数为空那么显示第二个参数的值,如果第一个参数的值不为空,则显示第一个参数本来的值。
在这里写一个oralce数据库换mysql数据例子:
原来的oralce语句如下:
create or replace view v_ms_reconductplanunvaliable as
(
(select.........,
sum(nvl(r.frecnum,0)*nvl(r.ftranRelation,1)) as unvaliableNum
from.........and.........
group by ...........
)
union all (
select...............,
sum(nvl(r.fapprovenum,0)*nvl(r.ftranRelation,1)) as unvaliableNum
from.................and.................
group by..................
)
union all (
select .................,
sum(nvl(r.foutnum,0)*nvl(r.ftranRelation,1)) as unvaliableNum
from.................. and.............
group by........................
)
);
换成mysql语句如下:
create or replace view v_ms_reconductplanunvaliable as
select r.fuseplanid,r.fuseplandetid,r.fmaterialid,r.fbatch,
sum(IFNULL(r.frecnum,0)*IFNULL(r.ftranRelation,1)) as unvaliableNum
from .....
group by .....
union all
select ......,
sum(IFNULL(r.fapprovenum,0)*IFNULL(r.ftranRelation,1)) as unvaliableNum
from .. and (...)
group by .....
union all
select .................,
sum(IFNULL(r.foutnum,0)*IFNULL(r.ftranRelation,1)) as unvaliableNum
from ...................and t.fuse='' and ..........
group by .........
去掉前后去掉括号,以适用于union 函数。
- oracle中nvl函数在mysql里面怎么使用
- mysql中类似oracle nvl()函数ifnull()
- 在oracle中函数NVL是什么意思?
- oracle中nvl()函数
- oracle中nvl()函数
- Oracle中nvl函数
- oracle中nvl()函数
- oracle中nvl()函数
- oracle中nvl()函数
- oracle中nvl()函数
- mysql中替代oracle中nvl()函数的ifnull()函数
- 在oracle的聚合函数(sum、avg等)中使用NVL函数,强迫加入空值
- ORACLE 中 NVL 函数使用方法
- oracle nvl函数的使用
- Oracle中Decode(),sign ,NVL ,trunc 函数使用技巧
- Oracle中Decode()、nvl(),sign()函数使用技巧
- oracle数据库中nvl使用
- oracle中NVL函数的使用方法
- ngnix多个域名的配置
- [转]高压缩空间占用的 Hyper LogLog 算法
- Linux中yum命令详解
- Android Ant打包
- iOS https自签名证书— xxx.crt 转化成xxx.cer 格式
- oracle中nvl函数在mysql里面怎么使用
- 谁是窃贼
- HashMap的put和get方法原理
- Mac上安装与使用MYSQL
- 对依赖、关联、聚合和组合之间区别的理解
- phpLib简单教程
- 设计模式之工厂模式
- React学习之路----3(组件化)
- web开发奇怪问题