12

Subqueries

In this chapter:

  • What is a subquery?

  • What are the types of subqueries?

  • Where can subqueries be used?

  • Why do we need subqueries?

Subqueries are probably one of the more complex aspects of SQL. Sub-queries are often used to resolve complexity by breaking down large queries into many smaller queries, which interact with each other. In some situations, subqueries can also be used to improve SQL statement performance. Let’s begin by looking at types of subqueries.

12.1 Types of Subqueries

I like to think of subqueries such that there are two methods of categorizing subqueries. The first method of categorization is that a subquery can be scalar, correlated, nested, or an inline view. We will get to some of these types of subqueries ...

Get Oracle SQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.