Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need SQL help
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
01473141
Message ID:
01473144
Vues:
70
>>Hi All -
>>
>>I am experiencing a bit of brain deadness this morning. I set out to write what I thought would be a rather simple SQL select statement but I just can't seem to get my head around it. Thus my plea for help. There are 2 tables CUSTOMERS and ORDERS. Common field is custID. I want to select all customers and the _date and amount of their most recent order (one record per customer). Can someone help me figure out how to do this?
>>
>>Thanks
>
>What DB you use?
>VFP - what version?
>SQL Server - what version?
>Other?


Using VFP:
select Cust.*, Ord.Amount. Ord.Date from Customers Cust INNER JOIN Orders Ord on Cust.CustNo = Ord.CustNo ;
where Ord.OrderID = (select top 1 OrderID from Orders O where O.CustNo = Cust.CustNo ORDER BY OrderDate DESC)
This is one of the possible variations of this query.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform