Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Last 3 orders from each customer - sql puzzle
Message
De
27/09/1999 12:50:42
 
 
À
25/09/1999 15:52:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00268263
Message ID:
00269455
Vues:
29
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform