Greg Larsen builds a subquery:
Did you know you can include a
SELECT
statement within anotherSELECT
statement? When aSELECT
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.
Greg has a good write-up on the topic of subqueries and does well to separate correlated from non-correlated subqueries.. And if you want to learn more about those, as well as common table expressions, I put out a video on the topic just last week.