Monday, January 25, 2010

Derived Table

When you use a result set of SELECT statement as table for FROM clause this called Derived Table or Virtual Table.
View or Temp table can give you the same result of Derived table but not simple as Derived Table because With the temporary tables you need to have multiple steps in your process, first to create the temporary table, then to populate the temporary table, then to select data from the temporary table and lastly cleanup of the temporary table. With the view approach you need to create the view and then use the view in your query.
Let's see an example:



The main benefit of a derived table is the fact that the result set resides entirely in memory, which allows faster data access than if the result set were on a storage device.

No comments: