From the course: Oracle Database 12c: Advanced SQL

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Using correlated subqueries

Using correlated subqueries

- [Instructor] We can also use a type of subquery known as a correlated subquery. Unlike the regular subqueries we used in our previous videos where the external query depends on values provided by the inner query, a correlated subquery is a type of subquery where the inner query depends on values provided by the external query. With a correlated subquery, the inner query is executed multiple times, once actually for each row that might be selected by the outer query. It might sound confusing on a theoretical level but once you see a demo, you'll understand how simple correlated subqueries are and how useful they can be. So let's say you want to select the list of employees that earned a higher salary when compared to the average salary of their departments. Going to our exercise file, you can find the correlated subquery demo provided. Let's copy this query and paste it to our SQL developer window. In this example, the inner query we have right here compares the employee department…

Contents