Home » Oracle » 1z0-071 v.2 » Which statement is true regarding the outcome?
The PRODUCTS table has the following structure.
Evaluate the following two SQL statements:
SQL>SELECT prod_id, NVL2 (prod_expiry_date, prod_expiry_date + 15, ‘ ‘) FROM products; SQL>SELECT prod_id, NVL (prod_expiry_date, prod_expiry_date + 15) FROM products;
Which statement is true regarding the outcome?
A. Both the statements execute and give different results
B. Only the second SQL statement executes successfully
C. Both the statements execute and give the same result
D. Only the first SQL statement executes successfully
Correct Answer: A
Explanation/Reference:
Explanation:
Using the NVL2 Function
The NVL2 function examines the first expression. If the first expression is not null, the NVL2 function returns the second expression. If the first expression is null, the third expression is returned. Syntax
NVL2(expr1, expr2, expr3) In the syntax:
Expr1 is the source value or expression that may contain a null
Expr2 is the value that is returned if expr1 is not null
Expr3 is the value that is returned if expr1 is null
Download Printable PDF. VALID exam to help you PASS.
|
|
A
If prod_expire_date is NOT NULL then first query returns prod_expiry_date + 15 but second query returns prod_expiry_date