sajad torkamani

An uncorrelated subquery is an SQL subquery that doesn’t refer to values in the outer query and can be executed independently. It executes just once and its result is used in the outer query.

Here’s an example uncorrelated subquery:

SELECT name, salary
FROM employees
WHERE salary > (
  SELECT AVG(salary)
  FROM employees
);

The subquery SELECT AVG(salary) FROM employees doesn’t depend on any values in the outer query and can be extracted to run independently.

Links

Tagged: SQL