Bird
0
0

Which of the following best describes the behavior of the SQL function COALESCE?

easy📝 Conceptual Q1 of 15
SQL - CASE Expressions
Which of the following best describes the behavior of the SQL function COALESCE?
AReturns NULL if all expressions are non-NULL
BReturns the first non-NULL value from a list of expressions
CReturns the last value in a list regardless of NULLs
DReturns the count of non-NULL values in a list
Step-by-Step Solution
Solution:
  1. Step 1: Understand COALESCE

    COALESCE evaluates its arguments in order and returns the first non-NULL value.
  2. Step 2: Analyze options

    Returns the first non-NULL value from a list of expressions correctly states this behavior. Options B, C, and D describe incorrect behaviors.
  3. Final Answer:

    Returns the first non-NULL value from a list of expressions -> Option B
  4. Quick Check:

    COALESCE(NULL, NULL, 5, 10) returns 5 [OK]
Quick Trick: COALESCE picks first non-NULL value [OK]
Common Mistakes:
  • Thinking COALESCE returns last value
  • Assuming COALESCE counts non-NULLs
  • Believing COALESCE returns NULL if any value is NULL

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes