>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only