Exam 1z0-082 All QuestionsBrowse all questions from this exam
Question 112

Which two queries execute successfully? (Choose two.)

    Correct Answer: D, E

    SELECT COALESCE(100, NULL, 200) FROM DUAL; executes successfully because COALESCE returns the first non-null value in its list of arguments, which in this case is 100. SELECT NULLIF(100, 100) FROM DUAL; also executes successfully because NULLIF returns NULL if both arguments are equal, which they are in this case. SELECT NULLIF(NULL, 100) FROM DUAL; causes an error because NULL cannot be compared directly. SELECT NULLIF(100, 'A') FROM DUAL; and SELECT COALESCE(100, 'A') FROM DUAL; cause errors because NULLIF and COALESCE require all arguments to be of the same data type, and mixing numbers and strings leads to data type inconsistency.

Discussion
BolilloOptions: DE

Tested both

ivanadjOptions: DE

D and E are correct SQL> SELECT COALESCE(100, NULL, 200) FROM DUAL; COALESCE(100,NULL,200) ---------------------- 100 SQL> SELECT NULLIF(100, 100) FROM DUAL; NULLIF(100,100) ---------------

auwiaOptions: DE

D and E are correct.

RaNik69Options: DE

D E is correct. Easy to test

BeomKOptions: DE

D,E is correct A. ORA-00932: inconsistent datatypes: expected - got CHAR B. ORA-00932: inconsistent datatypes: expected NUMBER got CHAR C. ORA-00932: inconsistent datatypes: expected NUMBER got CHAR D. SQL> SELECT COALESCE(100, NULL, 200) FROM DUAL; COALESCE(100,NULL,200) ---------------------- 100 E. SQL> SELECT NULLIF(100, 100) FROM DUAL; NULLIF(100,100) ---------------

Oracle2020Options: DE

D, E confirmed

Oracle2020

NULLIF must have the same data type, not use number and string in the same expression. COALESCE returns the first non-null value of the expression, but without using numbers and string.

hezzyOptions: DE

D and E .Confirmed.