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 |
danyeung
Posting Yak Master
102 Posts |
Posted - 2006-08-14 : 18:09:07
|
Can I get a dataset in stored procedure and use the dataset to join with and other table? For example, Select top 5 ProductName, sum(TotHours) as Hours from Table1 where entrydate = ‘08/11/2006’ group by ProductNameorder by Hours descHow do I store the result1 (example below) so that I can use it again in the stored procedure?ProeuctName HoursProductA 150ProductB 120ProductC 110Select * from (result1) where ProductName not in (select ProductName from Table2)Thanks.DanYeung |
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2006-08-14 : 19:29:03
|
From the looks of it you can get it in one statement:Select top 5 t1.ProductName, sum(t1.TotHours) as Hoursfrom Table1 t1left join Table2 t2 on t1.ProductName = t2.ProductNamewhere t1.entrydate = '08/11/2006' and t2.ProductName is nullgroup by t1.ProductNameorder by t1.Hours desc Nathan Skerl |
 |
|
danyeung
Posting Yak Master
102 Posts |
Posted - 2006-08-15 : 12:01:50
|
Thanks.DanYeung |
 |
|
|
|
|