OCP-1Z0-051-V9.02-98题

98. Which statement is true regarding the COALESCE function?

A. It can have a maximum of five expressions in a list. 最多只能有5个表达式,错,无限个

B. It returns the highest NOT NULL  value in the list for all rows. 返回最高的非空值,错,返回第一个非空值

C. It requires that all expressions in the list must be of the same data type. 所有都要相同的类型

D. It requires that at least one of the expressions in the list must have a NOT NULL  value. 至少有一个不是空值,错,可以都是空值,则返回空值

Answer: C

答案解析:

Purpose

 

COALESCE (expression_1, expression_2, ...,expression_n)

列表中第一个非空的表达式是函数的返回值,如果所有的表达式都是空值,最终将返回一个空值。

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.

Oracle Database uses short-circuit evaluation. The database evaluates each expr value and determines whether it is NULL, rather than evaluating all of the expr values before determining whether any of them is NULL.

If all occurrences of expr are numeric data type or any nonnumeric data type that can be implicitly converted to a numeric data type, then Oracle Database determines the argument with the highest numeric precedence, implicitly converts the remaining arguments to that data type, and returns that data type.

This function is a generalization of the NVL function.

You can also use COALESCE as a variety of the CASE expression. For example,

COALESCE(expr1, expr2)

is equivalent to:

CASE WHEN expr1 IS NOT NULL THEN expr1 ELSE expr2 END

Similarly,

COALESCE(expr1, expr2, ..., expr n)

where n >= 3, is equivalent to:

CASE WHEN expr1 IS NOT NULL THEN expr1
   ELSE COALESCE (expr2, ..., expr n) END
 
 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值