Subqueries and Derived Tables

Subqueries are special cases of queries within queries. They eliminate the need to save data in temporary tables or variables so that it can be used in subsequent queries later in your code. They also provide you with an alternative to joins (described in Chapter 1) for obtaining the same result set. Indeed, many subqueries can be reduced to an equivalent join, as this chapter explains. The chapter also describes situations where a join won’t do and you have to go with a subquery.