Part 76: Subqueries in the FROM Clause (Derived Tables)

Part 76 Technology Updated September 12, 2026

Part 76: Subqueries in the FROM Clause (Derived Tables)

Using the result of a subquery as a temporary virtual table inside the FROM clause.


1. Syntax

-- Calculate the average of department totals:
SELECT AVG(dept_summary.dept_total) AS avg_dept_payroll
FROM (
  SELECT department, SUM(salary) AS dept_total
  FROM employees
  GROUP BY department
) AS dept_summary; -- Derived tables MUST have an alias!

Key Takeaways

  • All derived tables in the FROM clause require an explicit alias.

In Part 77, we will explore Combining Results with UNION and UNION ALL!