Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Last 3 orders from each customer - sql puzzle
Message
De
24/09/1999 10:33:56
 
 
À
23/09/1999 20:25:41
Cindy Winegarden
Duke University Medical Center
Durham, Caroline du Nord, États-Unis
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:
00268493
Vues:
26
Thank you Cindy. I used your suggestion, and ended up with a working solution that looks like this:

set escape on
set safety off
SELECT 1
USE customer.dbf
SET ORDER TO customer_i
GO TOP
SELECT 2
USE orders.dbf
INDEX ON order_date TAG order_date DESCENDING
SELECT 3
USE lastget.dbf
zap

SELECT 1
DO WHILE NOT EOF()
m_customer_id = customer_id
SELECT TOP 3 Customer.customer_id, Orders.order_id, Orders.order_date;
FROM tastrade!orders INNER JOIN tastrade!customer ;
ON Orders.customer_id = Customer.customer_id;
WHERE Orders.customer_id = M_customer_id;
ORDER BY Customer.customer_id, Orders.order_date DESC;
INTO TABLE tempget.dbf
SELECT 3
APPEND FROM tempget.dbf
SELECT 1
Skip 1 && Move down one record
ENDDO
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform