Predict COUNT with NULL
Predict Output Medium
Question
A table has 5 rows. The 'email' column has 3 non-NULL values and 2 NULLs. What does COUNT(email) return?
Code
SELECT COUNT(email) FROM users;
Hint
COUNT(column) ignores NULL values.
Explanation
COUNT(email) counts only non-NULL values in the email column. With 3 non-NULL and 2 NULL values, the result is 3. (COUNT(*) would return 5.)
Related Resources
Related Lessons
- Aggregations
Learn COUNT with NULLs.
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.