0
0
SQLquery~5 mins

COALESCE for NULL handling in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the SQL function COALESCE do?
COALESCE returns the first non-NULL value from a list of expressions. If all values are NULL, it returns NULL.
Click to reveal answer
beginner
How does COALESCE help with NULL values in SQL queries?
It allows you to replace NULL values with a default or alternative value, making results easier to read and process.
Click to reveal answer
beginner
Example: What is the result of COALESCE(NULL, NULL, 'apple', 'banana')?
The result is 'apple' because it is the first non-NULL value in the list.
Click to reveal answer
beginner
Can COALESCE take more than two arguments?
Yes, COALESCE can take two or more arguments and returns the first non-NULL among them.
Click to reveal answer
intermediate
How is COALESCE different from ISNULL or NVL?
COALESCE is standard SQL and can take multiple arguments, while ISNULL (SQL Server) and NVL (Oracle) usually take two arguments and are vendor-specific.
Click to reveal answer
What will COALESCE(NULL, 'Hello', 'World') return?
A'Hello'
B'World'
CNULL
DError
If all arguments in COALESCE are NULL, what is the result?
AEmpty string
BNULL
C0
DError
Which of these is a valid use of COALESCE?
ACOALESCE(column1, column2, 'default')
BCOALESCE('default')
CCOALESCE()
DCOALESCE(NULL)
COALESCE is most similar to which function?
ASUM
BCOUNT
CISNULL
DAVG
What does COALESCE(NULL, NULL, NULL) return?
AError
B0
CEmpty string
DNULL
Explain how COALESCE helps handle NULL values in SQL queries.
Think about what happens when you have missing data.
You got /3 concepts.
    Write a simple SQL example using COALESCE to replace NULL with 'N/A'.
    Use COALESCE with two arguments.
    You got /3 concepts.