95.The PRODUCTS table has the following structure:
name Null Type
PROD_ID NOT NULL NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_EXPIRY_DATE DATE
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.Both the statements execute and give the same result.
C.Only the first SQL statement executes successfully.
D.Only the second SQL statement executes successfully.
答案:A
解析:
nvl2(expr1,expr2,expr3):expr1为null,返回expr3,否则返回expr2
nvl(expr1,expr2):expr1为null,返回expr2
name Null Type
PROD_ID NOT NULL NUMBER(4)
PROD_NAME VARCHAR2(25)
PROD_EXPIRY_DATE DATE
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.Both the statements execute and give the same result.
C.Only the first SQL statement executes successfully.
D.Only the second SQL statement executes successfully.
答案:A
解析:
nvl2(expr1,expr2,expr3):expr1为null,返回expr3,否则返回expr2
nvl(expr1,expr2):expr1为null,返回expr2