Challenge - 5 Problems
NULL Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Find rows with NULL values
Given a table Employees with columns
id, name, and manager_id (which can be NULL), which query returns all employees who do not have a manager assigned?SQL
SELECT * FROM Employees WHERE manager_id IS NULL;
Attempts:
2 left
💡 Hint
Remember that NULL is not equal to anything, even NULL itself.
✗ Incorrect
In SQL, to check for NULL values, you must use IS NULL. Using '=' or '!=' with NULL does not work as expected and returns no rows.
❓ query_result
intermediate2:00remaining
Exclude rows with NULL values
Which query returns all rows from the Orders table where the
shipped_date is known (not NULL)?SQL
SELECT * FROM Orders WHERE shipped_date IS NOT NULL;
Attempts:
2 left
💡 Hint
Use the correct syntax to filter out NULL values.
✗ Incorrect
To find rows where a column is not NULL, use IS NOT NULL. Using '=' or '!=' with NULL does not work properly.
📝 Syntax
advanced2:00remaining
Identify the syntax error in NULL check
Which option contains a syntax error when trying to select rows where
email is NULL in the Users table?SQL
SELECT * FROM Users WHERE email IS NULL;
Attempts:
2 left
💡 Hint
Check how NULL comparisons are done in SQL.
✗ Incorrect
Using '=' with NULL is not a syntax error but returns no rows because NULL is not comparable with '='. The correct syntax is IS NULL.
❓ query_result
advanced2:00remaining
Count rows with NULL values
What is the result of this query on the Products table counting rows where
discount_price is NULL?SQL
SELECT COUNT(*) FROM Products WHERE discount_price IS NULL;
Attempts:
2 left
💡 Hint
COUNT(*) counts all rows that match the WHERE condition.
✗ Incorrect
The query counts all rows where discount_price is NULL, so it returns the number of products without a discount price.
🧠 Conceptual
expert2:00remaining
Understanding NULL behavior in WHERE clause
Consider the query:
SELECT * FROM Customers WHERE phone_number != '123-456-7890'; Which statement is true about rows where phone_number is NULL?Attempts:
2 left
💡 Hint
Think about how SQL treats NULL in comparisons.
✗ Incorrect
In SQL, any comparison with NULL returns UNKNOWN, so rows with NULL phone_number are excluded unless explicitly checked with IS NULL or IS NOT NULL.