oracle nvl,nvl2,coalesce几…

1.nvl(exp1,exp2)

NVL letsyou replace null (returned as a blank) with a string in the resultsof a query. If expr1 isnull, then NVL returns expr2.If expr1 isnot null, then NVL returnsexpr1.

该函数是处理表达式中的空值:如果表达式exp1是空值,则该函数返回表达式exp2的值,

                    如果表达式exp1不是空值,则该函数返回表达式exp1的值。

2.nvl2(exp1,exp2,exp3)

NVL2 letsyou determine the value returned by a query based on whether aspecified expression is null or not null.If expr1 isnot null,then NVL2 returns expr2.Ifexpr1 isnull, then NVL2 returns expr3.

该函数决定exp1分别是空值和非空值时返回哪个表达式:

                   如果exp1为空值,则返回exp3

                                     如果exp1非空,返回exp2。

3.coalesce(exp1,exp2,.....)

COALESCE returnsthe first non-null expr inthe expression list. You must specify at least two expressions. Ifall occurrences of expr evaluateto null, then the function returns null.

该函数在括号里所有的表达式中返回第一个非空值,如果都是空值,则返回空值,表达式至少是两个。

例子:

oracle <wbr>nvl,nvl2,coalesce几个函数的区别
这个例子里面,是显示产品的售价,在标价(list_price)的基础上打九折,如果标价为空,则显示最低价(min_price),如果标价和最低价都为空,则显示5。

4.补充一下最后一个nullif

nullif(expression1,expression2) 如果两个表达式相等,则返回null,如果不相等,则返回expression1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

科技改变未来

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值