AI engineering glossary · SQL databases
What is correlated subquery?
Correlated subquery: A subquery that refers to columns of the outer query, so it is logically re-evaluated for each outer row. It can be slow if the optimiser cannot rewrite it as a join.
Correlated subquery: an example
For each employee, (SELECT MAX(salary) FROM employees WHERE dept = e.dept) finds the highest salary in that employee's department.
Related terms
More SQL databases terms
Where you learn it
Correlated subquery is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.