Recall & Review
beginner
What is a subquery in SQL?
A subquery is a query nested inside another query. It helps to get intermediate results that the main query can use.
Click to reveal answer
beginner
Why do we use subqueries instead of writing one big query?
Subqueries break complex problems into smaller steps, making queries easier to write and understand.
Click to reveal answer
intermediate
How do subqueries help when filtering data?
Subqueries can find a set of values first, then the main query uses those values to filter results precisely.
Click to reveal answer
intermediate
Can subqueries be used in SELECT, WHERE, and FROM clauses?
Yes, subqueries can appear in SELECT to calculate values, in WHERE to filter rows, and in FROM to act like temporary tables.
Click to reveal answer
beginner
Give a real-life example of why subqueries are useful.
Imagine finding customers who bought the most expensive product. A subquery finds the max price, then the main query finds customers who bought that product.
Click to reveal answer
What is the main reason to use a subquery?
✗ Incorrect
Subqueries help simplify complex queries by breaking them into smaller, manageable parts.
Where can a subquery NOT be used?
✗ Incorrect
Subqueries cannot be used as standalone queries in ORDER BY; they must be part of a valid SQL expression.
Which of these is a benefit of using subqueries?
✗ Incorrect
Subqueries help organize complex logic, making queries easier to understand and maintain.
What does a subquery inside a WHERE clause usually do?
✗ Incorrect
A subquery in WHERE filters rows by comparing values to the subquery's result.
If you want to find customers who bought the most expensive product, what would you use?
✗ Incorrect
You use a subquery to find the max price first, then find customers who bought that product.
Explain in your own words why subqueries are useful in SQL.
Think about how breaking a big task into smaller steps helps you solve it.
You got /4 concepts.
Describe a real-life scenario where using a subquery would help solve a database question.
Imagine you want to find something special based on a condition that needs calculation first.
You got /3 concepts.