In this article I’ll speak about improvements that were made by Oracle 12c and SQL, such as the phrases LATERAL, CROSS APPLY and OUTER APPLY. I hope this will be a helpful article in terms of awareness.

When writing queries in database versions before Oracle 12c, we weren’t able to use correlated subquery in the FROM section of our query. With Oracle 12c, the basis for our uses and needs of this sort has been accessed.

Now, let’s figure out how this structure works through some examples.

First of all, let’s look at the result that we get when we run the query below in 11g database.

So, subselect that we wrote in from section of our query is dependent on employees table that we used externally.
Due to this dependence, Oracle could not recognize the external-dependent parameter in subquerry, and received an error. And this is the very point on which Oracle made the necessary improvements, thus paving the way for the user for these kinds of uses.
Now, let’s try to substantiate this need on 12c database.

We can see that the result returns successfully when we run our query. With this command, now we could use correlated subquerry on FROM side. What about execution plan of our query, though?

Now, let’s examine CROSS APPLY and OUTER APPLY. CROSS APPLY and OUTER APPLY also run in a similar way to LATERAL basis, and serves a similar need. The differences between are: if wer run CROSS APPLY, it automatically applies CROSS JOIN on tables/inline views that we wrote in FROM. If we use OUTER APPLY, it applies LEFT OUTER JOIN on tables/inline views that we wrote in FROM.
Now, let’s see how to use both these two commands.