Final answer:
A correlated query is used to test for a relationship or link between the subquery and the outer query, with the subquery being dependent on values from each row of the outer query. Correct answer is 4) To combine the results of the subquery and the outer query.
Step-by-step explanation:
The purpose of a correlated query is to test whether a relationship or link is present between the subquery and the outer query. Unlike regular subqueries, a correlated subquery cannot execute independently of the outer query because it uses values from the outer query within its WHERE clause. Essentially, for each row processed by the outer query, the subquery is re-executed, using the outer query's current row values to determine the specific results returned for that row.
This type of query is useful when you need to compare each row in the main query with a set of rows from a subquery. This could be used to filter results in the outer query based on conditions applied to rows returned by the subquery. For example, if you want to find employees whose salaries are above the average of their respective departments, the correlated query allows you to calculate the average salary for the department of each employee and then compare it to that employee's salary. Correct answer is 4) To combine the results of the subquery and the outer query.