Locked lesson.
About this lesson
Exercise files
Download this lesson’s related exercise files.
Subqueries.docx59.1 KB Subqueries - Solution.docx
59.1 KB
Quick reference
Subqueries
A Subquery is a Query inside of another Query.
When to use
Use them whenever you need to run more than one select statement at a time.
Instructions
Subqueries are made of inner queries and outer queries. Simply wrap your outer query (the 2nd select statement) in parenthesis (), and then paste it into your first query.
SELECT [First Name], [Last Name]
FROM [dbo].[Current_Customers]
WHERE [Customer ID] IN (SELECT [CUSTOMER ID]
FROM [dbo].[Current_Customers]
WHERE [CUSTOMER ID] > 4)
Hints & tips
- A Subquery is a Query inside of another Query.
- Subqueries can go inside select statements, and where statements and all kinds of places.
Lesson notes are only available for subscribers.