Challenge - 5 Problems
Master of SELECT Processing
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of SELECT with WHERE and ORDER BY
Given the table Employees with columns
id, name, and salary, what is the output of this query?SELECT name FROM Employees WHERE salary > 50000 ORDER BY name ASC;
SQL
CREATE TABLE Employees (id INT, name VARCHAR(50), salary INT); INSERT INTO Employees VALUES (1, 'Alice', 60000), (2, 'Bob', 45000), (3, 'Charlie', 70000); SELECT name FROM Employees WHERE salary > 50000 ORDER BY name ASC;
Attempts:
2 left
💡 Hint
Think about filtering first, then sorting alphabetically.
✗ Incorrect
The query filters employees with salary greater than 50000, which are Alice and Charlie. Then it orders them by name ascending, so Alice comes before Charlie.
🧠 Conceptual
intermediate2:00remaining
Order of operations in SELECT processing
In what order does the database engine process the clauses in a SELECT statement?
Attempts:
2 left
💡 Hint
Think about which clause filters rows first and which one selects columns.
✗ Incorrect
The database engine processes FROM first to get data, then WHERE to filter rows, then GROUP BY to group rows, HAVING to filter groups, SELECT to choose columns, and ORDER BY to sort the final result.
📝 Syntax
advanced2:00remaining
Identify the syntax error in this SELECT query
Which option contains a syntax error when trying to select all columns from
Products where price is less than 100?Attempts:
2 left
💡 Hint
Check the FROM clause syntax carefully.
✗ Incorrect
Option B is missing the FROM keyword before the table name, causing a syntax error.
❓ optimization
advanced2:00remaining
Optimizing SELECT with JOIN and WHERE
Given two tables
Orders and Customers, which query is more efficient to find orders from customers in 'New York'?Attempts:
2 left
💡 Hint
Consider how JOINs and subqueries affect query planning.
✗ Incorrect
Option D uses an explicit JOIN which is generally more efficient and clearer for the database optimizer than subqueries or implicit joins.
🔧 Debug
expert2:00remaining
Why does this SELECT query return no rows?
Consider these tables:
Why does this query return no rows?
Users(id, name)
Orders(id, user_id, total)
Why does this query return no rows?
SELECT u.name FROM Users u LEFT JOIN Orders o ON u.id = o.user_id WHERE o.total > 100;
Attempts:
2 left
💡 Hint
Think about how WHERE affects rows after a LEFT JOIN.
✗ Incorrect
The LEFT JOIN keeps all users, but the WHERE clause filters rows where o.total > 100. For users without orders, o.total is NULL, so the condition fails and those rows are removed, resulting in no rows if no orders have total > 100.