Correlated subqueryCorrelated subqueries may appear elsewhere besides the WHERE clause; for example, this query uses a correlated subquery in the SELECT clause to print the entire list of employees alongside the average salary for each employee's department.
Again, because the subquery is correlated with a column of the outer query, it must be re-executed for each row of the result.
WHERE department = Bob.department) AS department_average
FROM employees AS Bob
group by employee_number,name ;