Quiz on SQL Correlated Subquery
A correlated subquery is a subquery that refers to columns from the outer query. Unlike regular subqueries, it is evaluated once per row of the outer query, making it useful for row-wise comparisons.
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 15 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- Current
- Review / Skip
- Answered
- Correct
- Incorrect
- Question 1 of 15
1. Question
What is a correlated subquery in SQL?
CorrectIncorrect - Question 2 of 15
2. Question
In a correlated subquery, which clause typically contains the subquery?
CorrectIncorrect - Question 3 of 15
3. Question
What is the main difference between a regular subquery and a correlated subquery?
CorrectIncorrect - Question 4 of 15
4. Question
What happens if a correlated subquery is placed in the WHERE clause?
CorrectIncorrect - Question 5 of 15
5. Question
Which of the following is an example of a correlated subquery?
SELECT name
FROM employees e
WHERE salary > (SELECT AVG(salary) FROM employees);CorrectIncorrect - Question 6 of 15
6. Question
Identify the correlated subquery:
SELECT name
FROM employees e
WHERE salary > (SELECT AVG(salary) FROM employees d WHERE d.department = e.department);CorrectIncorrect - Question 7 of 15
7. Question
Can a correlated subquery return multiple rows?
CorrectIncorrect - Question 8 of 15
8. Question
What is the purpose of a correlated subquery in SQL?
CorrectIncorrect - Question 9 of 15
9. Question
What is the performance drawback of correlated subqueries?
CorrectIncorrect - Question 10 of 15
10. Question
Which of the following queries finds employees with salaries above their department’s average?
SELECT name
FROM employees e
WHERE salary > (
SELECT AVG(salary)
FROM employees d
WHERE d.department = e.department
);CorrectIncorrect - Question 11 of 15
11. Question
What keyword is often used with correlated subqueries for efficiency?
CorrectIncorrect - Question 12 of 15
12. Question
Which statement is TRUE about correlated subqueries?
CorrectIncorrect - Question 13 of 15
13. Question
Which SQL engine feature can help improve correlated subquery performance?
CorrectIncorrect - Question 14 of 15
14. Question
Which clause is NOT suitable for placing a correlated subquery?
CorrectIncorrect - Question 15 of 15
15. Question
What does this query do?
SELECT e.name
FROM employees e
WHERE EXISTS (
SELECT 1
FROM projects p
WHERE p.lead_id = e.id AND p.status = ‘Active’
);CorrectIncorrect
Summary
A correlated subquery is evaluated per row of the outer query and allows comparisons using outer query columns. Though powerful, they can impact performance on large datasets and are sometimes replaceable with joins for better efficiency.
