SQL Subquery in FROM clause


Example

A subquery in a FROM clause acts similarly to a temporary table that is generated during the execution of a query and lost afterwards.

SELECT Managers.Id, Employees.Salary
FROM (
  SELECT Id
  FROM Employees
  WHERE ManagerId IS NULL
) AS Managers
JOIN Employees ON Managers.Id = Employees.Id