thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Intermediate

Derived Table

A subquery in the FROM clause that acts as a temporary inline table, which must have an alias.

Definition

Derived tables let you aggregate or filter before joining. They exist only for the duration of the query. A CTE does the same job and can be referenced more than once.

Example

SELECT d.DeptID, d.AvgSal FROM (SELECT DeptID, AVG(Salary) AS AvgSal FROM Employees GROUP BY DeptID) AS d;

Exam tip

Most dialects require an alias for a derived table.

Related terms