7.7. Subqueries
Now that we have seen how two or more tables can be combined in a join query, we turn our attention to another type of complex query known as a subquery. A subquery is a query expression that is nested within another query expression. Its purpose is to have the inner query produce a single value or multiple values that can then be passed into the outer query for processing. You achieve this by embedding a SELECT statement inside a WHERE clause of an outer query’s SELECT statement, INSERT statement, DELETE statement, or HAVING clause.
Note: | You should avoid nesting more than two subqueries deep because of the conceptual and processing complexities this introduces. |
The typical subquery consists of a (inner) query combined inside ...
Get PROC SQL: Beyond the Basics Using SAS® 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.