Recall & Review
beginner
What is a nested subquery in SQL?
A nested subquery is a query written inside another query. It helps to use the result of one query inside another query.
Click to reveal answer
beginner
Can a nested subquery return multiple rows?
Yes, a nested subquery can return multiple rows if used with operators like IN or EXISTS. But if used with =, it must return only one row.
Click to reveal answer
intermediate
How does a nested subquery help in filtering data?
A nested subquery can find a set of values or a single value that the outer query uses to filter its results, like finding employees who work in departments with more than 10 people.
Click to reveal answer
intermediate
What is the difference between a correlated and a non-correlated nested subquery?
A correlated subquery depends on the outer query for its values and runs once per row. A non-correlated subquery runs once and returns a result used by the outer query.
Click to reveal answer
beginner
Write a simple example of a nested subquery to find employees with salary above the average salary.
SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
Click to reveal answer
What does a nested subquery do in SQL?
✗ Incorrect
A nested subquery runs a query inside another query to use its result.
Which operator allows a nested subquery to return multiple rows?
✗ Incorrect
The IN operator allows a nested subquery to return multiple rows.
What is a correlated subquery?
✗ Incorrect
A correlated subquery depends on the outer query and runs once per row.
Which of these is a valid use of a nested subquery?
✗ Incorrect
Option C uses a nested subquery to compare salary with average salary.
If a nested subquery returns more than one row but is used with '=', what happens?
✗ Incorrect
Using '=' with multiple rows causes an error because '=' expects a single value.
Explain what a nested subquery is and give a simple example.
Think about a query inside another query.
You got /2 concepts.
Describe the difference between correlated and non-correlated nested subqueries.
Focus on how the subquery uses values from the outer query.
You got /3 concepts.