What is a subquery and when would you use it?
A subquery is a query within a query. It is used to retrieve data that will be used in the main
query.
Use case:
- Filtering: When the result of a subquery is used to filter data in the outer query.
- Aggregation: When the result of the subquery is used in aggregate functions.