Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Last 3 orders from each customer - sql puzzle
Message
From
27/09/1999 12:50:42
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00268263
Message ID:
00269455
Views:
30
Hi Michael,
Thanks for pursuit of the nested sql for this. I can't yet see a way.
Your code did something interesting, when I ran

SELECT TOP 3 order_id;
FROM orders;
ORDER BY order_date DESC;
INTO CURSOR top3

I got 5 records! Go figure.

The second Select with the nested sql did run when I assumed your example used orditems (you had ordlines). But I have no need for the line detail, just the last 3 orders.

Be that as it may, the results were not in three's. They match with top3, however.

SELECT *;
FROM orders INNER JOIN orditems;
ON orders.order_id = orditems.order_id;
WHERE orders.order_id IN;
(SELECT order_id FROM top3)

-Sylvia
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform