Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MSDE/SQL Server/etc - Stored procedures and such
Message
From
16/08/2003 12:47:46
 
 
To
16/08/2003 12:34:02
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00820729
Message ID:
00820786
Views:
23
>I understand that SQL Server allows that, but what I'm missing (I think) is... from one SELECT to the next, how does SQL Server know to keep the prior results around for later use IF I have sent the SELECTs each independently to it (as looks like would be the case with my present code)?
>


Because a dervied table is just part of the query... For example, lets say you have:

VFP:

SELECT sum(sales), salesman_id
FROM sales
GROUP BY salesman_id
IN CURSOR salesamount

SELECT *
FROM salesmen s
JOIN salesamount a ON s.salesman_id = a.salesman_id
ORDER by s.lastname

********************
In sql server, you can use the first select as a derived table in the second select. So, the single select statement would be:

SELECT *
FROM salesmen s
JOIN (
SELECT sum(sales), salesman_id
FROM sales
GROUP BY salesman_id
) a ON s.salesman_id = a.salesman_id


**********
BOb
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform