Challenge - 5 Problems
WHERE Clause Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Filter employees with salary greater than 50000
Given a table employees with columns
id, name, and salary, which query returns all employees earning more than 50000?MySQL
SELECT * FROM employees WHERE salary > 50000;
Attempts:
2 left
💡 Hint
Think about the meaning of the > operator in filtering salaries.
✗ Incorrect
Option C correctly filters employees with salary strictly greater than 50000. Option C filters salaries less than 50000, Option C includes 50000 itself, and D filters only those exactly equal to 50000.
❓ query_result
intermediate2:00remaining
Find customers from specific cities
Given a table customers with columns
id, name, and city, which query returns customers from either 'New York' or 'Los Angeles'?MySQL
SELECT * FROM customers WHERE city = 'New York' OR city = 'Los Angeles';
Attempts:
2 left
💡 Hint
Use OR to include multiple possible values.
✗ Incorrect
Option A correctly uses OR to select customers from either city. Option A is valid SQL but not the exact query given. Option A uses AND which is impossible for one city to be both. Option A uses LIKE but without wildcards, so it behaves like =.
📝 Syntax
advanced2:00remaining
Identify the syntax error in this WHERE clause
Which option contains a syntax error in the WHERE clause?
MySQL
SELECT * FROM orders WHERE order_date BETWEEN '2023-01-01' AND '2023-12-31';
Attempts:
2 left
💡 Hint
Check the correct syntax for BETWEEN operator.
✗ Incorrect
Option D uses 'TO' instead of 'AND' in BETWEEN clause, which is invalid syntax. Options B, C, and D are syntactically correct.
❓ optimization
advanced2:00remaining
Optimize filtering for multiple values
Which query is the most efficient way to filter rows where
status is 'active', 'pending', or 'suspended'?Attempts:
2 left
💡 Hint
Use a concise operator for multiple values.
✗ Incorrect
Option B uses IN which is more concise and optimized for multiple values. Option B works but is longer. Option B is logically impossible. Option B uses LIKE unnecessarily.
🧠 Conceptual
expert2:00remaining
Understanding NULL filtering in WHERE clause
Given a table products with a column
discount that can be NULL, which query correctly selects products with no discount?Attempts:
2 left
💡 Hint
Remember how SQL treats NULL comparisons.
✗ Incorrect
Option A correctly uses IS NULL to check for NULL values. Options B and D use = or != with NULL which always return false. Option A checks for zero discount, not NULL.