Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • Derived tables are great are are usually faster than correlated subqueries. YOu can also use with staements instead but frankly I find them harder to read and interpret (of course I've been reading derived tables for ten years). One thing to remember is that any derived tblae must be a given an alias or the query will not work. Commented Oct 1, 2010 at 21:40
  • I am speaking from the context of comparably large datasets (though, of course I could still be wrong!). Let's say I wanted to join an aggregate sum within a date range. The derived table is queried before it's assigned to its alias. So it should be faster to say JOIN (select sum(a), b from table where b = c group by b) d than it would be to do JOIN (select sum(a), b from table group by b) d WHERE d.b = c Commented Oct 4, 2010 at 16:59