派生表

SQL Server 中级

Ginger Grant

Instructor

什么是派生表?

  • 作为临时表对待的查询
  • 始终包含在主查询内
  • FROM 子句中指定
  • 可含中间计算,供主查询使用,或使用与主查询不同的连接
SQL Server 中级

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 中级

让我们来练习!

SQL Server 中级

Preparing Video For Download...