About Correlated Subqueries

A correlated subquery is related to a subquery in that it uses an inner query to feed result values to the outer query. A normal subquery executes the inner and outer queries once, returning the value(s) from the inner query to the outer query. A correlated subquery executes the outer query multiple times, once for each row returned by the inner query. Interactive Reporting supports the graphical build of correlated subqueries by introducing the outer query back into the definition of the inner query in the subquery building process.

For example, suppose you had to identify which sales representatives had more sales in the current month than they did in the previous month. The correlated subquery is executed for each row of sales information in the parent query to first determine what were the sales for each representative in the previous month. This data, in turn, is compared to sales for each representative in the current month, and only those representatives whose sales in the current month were greater that their previous month’s sales are returned.