SQL Correlated Subqueries Explained
Quick Answer
A correlated subquery is a SQL subquery that references columns from the outer query, executing once for each row processed by the outer query. It allows row-by-row comparison and filtering, enabling complex queries that depend on outer query values.
Learning Objectives
- Define what a correlated subquery is and how it differs from a non-correlated subquery.
- Write SQL queries using correlated subqueries for row-wise filtering and comparison.
- Understand performance considerations and best practices when using correlated subqueries.
Introduction
SQL subqueries allow you to embed one query inside another to perform complex data retrieval.
Correlated subqueries are a special type of subquery that reference columns from the outer query, making them dependent on each row processed by the outer query.
A correlated subquery is like a nested loop that runs once for each row of the outer query.





