Using a Subquery in a SELECT statement


 

This article is part of Greg Larsen’s continuing series on Learning T-SQL. To see all 10 items in the series, click here.

Did you know you can include a SELECT statement within another SELECT statement? When a SELECT statement is embedded within another statement it is known as a subquery. There are two types of subqueries: basic subquery and correlated subquery.

In this article I will be discussing both types of subqueries and will be providing examples of how to use a subquery in different places within in a SELECT statement.

Difference between a basic subquery and a correlated subquery