A subquery is a query nested inside another query, allowing you to use the result of one query in another query.
Find employees earning above average
Customers who ordered specific products
Check existence of related records
Multi-step filtering
Checks if value exists in subquery
Example: WHERE ID IN (SELECT...)...
Checks if subquery returns rows
Example: WHERE EXISTS (SELECT 1...)...
Returns single value
Example: (SELECT AVG(Sales))...
References outer query
Example: WHERE Sales > (SELECT AVG FROM same table)...
Main query structure
Use IN or EXISTS
Enclose in parentheses
Subquery returns one column
Test subquery alone first
Put subquery in main query