Challenge - 5 Problems
Filtering Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Filtering rows with WHERE clause
Given the table Employees with columns
id, name, and department, what will be the output of this query?SELECT name FROM Employees WHERE department = 'Sales';
SQL
SELECT name FROM Employees WHERE department = 'Sales';
Attempts:
2 left
💡 Hint
Filtering with WHERE limits rows to those matching the condition.
✗ Incorrect
The WHERE clause filters rows to only those where department is 'Sales'. Only Alice and Bob belong to Sales.
🧠 Conceptual
intermediate1:30remaining
Why filtering improves query performance
Why is filtering data using conditions important in database queries?
Attempts:
2 left
💡 Hint
Think about how less data means faster work.
✗ Incorrect
Filtering limits data to only what is needed, so queries run faster and use fewer resources.
📝 Syntax
advanced2:00remaining
Identify the correct filtering syntax
Which of the following SQL queries correctly filters employees with salary greater than 50000?
Attempts:
2 left
💡 Hint
The WHERE clause is used for filtering rows before grouping.
✗ Incorrect
Option C uses correct WHERE syntax. A uses invalid FILTER keyword. C uses HAVING which is for groups. D has wrong operator => instead of >=.
❓ optimization
advanced2:30remaining
Effect of filtering on query optimization
Consider a large table
Orders. Which filtering approach helps the database optimize query performance best?Attempts:
2 left
💡 Hint
Indexes help the database find rows faster when filtering.
✗ Incorrect
Filtering on indexed columns with selective conditions allows the database to quickly locate relevant rows, improving performance.
🔧 Debug
expert3:00remaining
Why does this filtering query return no rows?
Given the query:
Why might this query return an empty result set?
SELECT * FROM Products WHERE price < 0;
Why might this query return an empty result set?
Attempts:
2 left
💡 Hint
Think about what values prices usually have.
✗ Incorrect
Prices are typically zero or positive, so filtering for price < 0 returns no rows.