oracle nvl,nvl2,coalesce几个函数的区别

1.nvl(exp1,exp2)

NVL lets you replace null (returned as a blank) with a string in the results of a query. If expr1 is null, then NVL returns expr2. If expr1 is not null, then NVL returnsexpr1.

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

假设表达式exp1没有是空值,则该函数返回表达式exp1的值。

2.nvl2(exp1,exp2,exp3)

NVL2 lets you determine the value returned by a query based on whether a specified expression is null or not null. If expr1 is not null, then NVL2 returns expr2. Ifexpr1 is null, then NVL2 returns expr3.

该函数决意exp1离去是空值和非空值时返回哪个表达式:

假设exp1为空值,则返回exp3

假设exp1非空,返回exp2

3.coalesce(exp1,exp2,…)

COALESCE returns the first non-null expr in the expression list. You must specify at least two expressions. If all occurrences of expr evaluate to null, then the function returns null.

该函数正在括号里全数的表达式中返回第一个非空值,假设都是空值,则返回空值,表达式最少是两个。


本文来源:https://www.cnblogs.com/xuyuanjia/p/6027226.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值