Question discussion

What is the output of the following SQL statement?SELECT COALESCE(NULL, NULL, 5, 6) + COALESCE(NULLIF(4, 4), 9);

1927Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following SQL statement?

SELECT COALESCE(NULL, NULL, 5, 6) + COALESCE(NULLIF(4, 4), 9);
  • ANULL
  • B15
  • C5
  • D14
Correct answer: D

Explanation

COALESCE returns the first non-NULL value, so the first term is 5; NULLIF(4, 4) is NULL, so the second COALESCE gives 9, and 5 + 9 = 14.

Discussion 0

Nobody has replied yet. Start the discussion!