Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
BitShift
Yak Posting Veteran
98 Posts |
Posted - 2006-09-26 : 09:19:00
|
I seen this in some sql we have and was curious that you could do a join on a resultset, not just another table. The code below is an example. Its part of a stored procedure that fetches some data and computes subtotals and a grand total, which it returns in seperate columns.select a.* from #atemp ajoin ( select a.bookid, [Part Num] from #atemp a group by a.bookid) bon a.bookid= b.bookidThis works, but my question is:- what kinds of situations would require you to join on a resultset ? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-26 : 09:22:33
|
Many cases. See this topic http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=72346 for one example.Actually all JOINS are on resultsets.The default INNER JOIN OtherTable ON OtherTable.SomeColumn is just a simpler way to writeINNER JOIN (select * from othertable) OtherTable ON OtherTable.SomeColumn Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|