Derived tables

SQL Server intermedio

Ginger Grant

Instructor

What are Derived tables?

  • Query which is treated like a temporary table
  • Always contained within the main query
  • They are specified in the FROM clause
  • Can contain intermediate calculations to be used the main query or different joins than in the main query
SQL Server intermedio

Derived tables in T-SQL

SELECT a.* FROM Kidney a
-- This derived table computes the Average age joined to the actual table 
JOIN (SELECT AVG(Age) AS AverageAge 
      FROM Kidney) b 
ON a.Age = b.AverageAge
SQL Server intermedio

Let's practice!

SQL Server intermedio

Preparing Video For Download...