beginnerSubqueries, EXISTS & Correlated Subqueries
What is the difference between a correlated and non-correlated subquery?
Non-correlated subquery: independent of the outer query. It executes ONCE and its result is used by the outer query. Example: WHERE salary > (SELECT AVG(salary) FROM employees) — inner query runs once, returns one value. Correlated subquery: references columns from the outer query. It executes ONCE FOR EACH ROW of the outer query. Example: WHERE salary > (SELECT AVG(salary) FROM employees e2 WHERE
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response