A subquery is a query that is nested inside a SELECT statement, an INSERT statement, a UPDATE statement, a DELETE statement, or inside another subquery. The AdventureWorks2016 database is used in the samples in this article and can be downloaded from AdventureWorks sample databases. Anywhere an expression is allowed, a subquery can be utilised.
Subqueries (also known as inner queries or nested queries) are a tool for performing operations in multiple steps. For example, if you wanted to take the sums of several columns, then average all of those values, you’d need to do each aggregation in a distinct step.
A subquery is a query that is nested within another subquery or within a SELECT, INSERT, UPDATE, or DELETE statement. The samples in this article make use of the AdventureWorks2016 database, which may be downloaded from the Adventure Works sample databases page. A subquery can be used wherever an expression is permitted.
