COALESCE Result
Predict Output Medium
Question
What does this SQL produce?
Code
-- users: (1,"Ada","[email protected]"), (2,"Bob",NULL)
SELECT name, COALESCE(email, "N/A") FROM users;
Hint
COALESCE returns the first non-NULL value.
Explanation
COALESCE(email, "N/A") returns email if not NULL, otherwise "N/A". Ada has an email, so it returns "[email protected]". Bob has NULL email, so it returns "N/A". Result: Ada/[email protected], Bob/N/A.
Related Resources
Related Lessons
- SQL Basics
Learn SQL.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.