Derived tables

SQL Server ระดับกลาง

Ginger Grant

Instructor

Derived tables คืออะไร?

  • คิวรีที่ถูกใช้งานเหมือนตารางชั่วคราว
  • อยู่ภายในคิวรีหลักเสมอ
  • ระบุไว้ในส่วน FROM
  • สามารถมีการคำนวณขั้นกลางเพื่อใช้ในคิวรีหลัก หรือใช้การ join ที่แตกต่างจากคิวรีหลักได้
SQL Server ระดับกลาง

Derived tables ใน 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...