Examine the data in the LIST_PRICE and MIN_PRICE columns of the PRODUCTS table:
Which two expressions give the same output? (Choose two.)
A.
NVL(NULLIF(list_price, min_price), 0)
B.
NVL(COALESCE(list_price, min_price), 0)
C.
NVL2(COALESCE(list_price, min_price), min_price, 0)
D.
COALESCE(NVL2(list_price, list_price, min_price), 0)
Explanation:
Using the COALESCE Function
• The advantage of the COALESCE function over the NVL function is that the COALESCE function can take
multiple alternate values.
• If the first expression is not null, the COALESCE function returns that expression; otherwise, it does a
COALESCE of the remaining expressions.
Using the COALESCE Function
The COALESCE function returns the first non-null expression in the list.
Syntax
COALESCE (expr1, expr2, .. exprn)
In the syntax:• expr1 returns this expression if it is not null
• expr2 returns this expression if the first expression is null and this expression is not null
• exprn returns this expression if the preceding expressions are null
Note that all expressions must be of the same data type.
B & D
a).NVL(NULLIF(list_price, min_price), 0)
o/p- 10,000 , 20,000, 0
B.
NVL(COALESCE(list_price, min_price), 0)
o/p- 10,000 ,20,000 ,30,000
C.
NVL2(COALESCE(list_price, min_price), min_price, 0)
o/p – 8000, NULL ,30,000
D.
COALESCE(NVL2(list_price, list_price, min_price), 0)
o/p- 10,000 ,20,000 ,30,000