- Category: SQL Subqueries
SQL Subqueries provide a powerful means to combine data from one or more table into one result. They are sometimes called nested queries. As the name implies, they one or more queries, one inside one another other.
IF you’re unfamiliar them, then your first order of business should be to read our article Ultimate Guide to Subqueries. This is super place to start.
Subqueries are slippery and our guide help you get a handle on all the places to use a sub query in your SQL. If you are just looking to learn sub queries, then this is a must read.
If you looking for advanced topics then check out Correlated Subqueries in SQL to see how to write SQL that is more data driven, and doesn’t need to rely on hard coded values.
Or check out our case study on using a Join, Union, and Subquery all in one SQL Statement! This is based on question I received from a reader. It a good read, and give you good insight into my approach to solving problems as well as writing SQL.
All the examples for this lesson are based on Microsoft SQL Server Management Studio and the sample databases AdventureWorks and WideWorldImporters. You can get started using these free tools using my guide Getting Started Using SQL Server