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.
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 ...