Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to select TOP 1 in a LEFT JOIN?
Message
 
 
À
29/07/2005 09:43:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
Database:
MS SQL Server
Divers
Thread ID:
01036783
Message ID:
01036944
Vues:
9
>
>Just thought I'd offer an alternate approach:
>
>SELECT CompanyName, OrderDate ;
> FROM Customers ;
> LEFT JOIN ;
> (SELECT CompanyID, MAX(OrderDate) AS OrderDate ;
> FROM Orders ;
> GROUP BY CompanyID) AS MaxOrders ;
> ON Customers.CompanyID = MaxOrders.CompanyID ;
> INTO CURSOR MostRecent
>
Hi Tamar,

Thank you for your suggestion. I will try it, just to learn something new. But, for some reason, I don't like using GROUP BY, it always gives me troubles. I think because I have to select only certain fields when using GROUP BY. So I kind of shy away from GROUP BY, if I can do without it. Don't take it personally though <g>. Thank you, again.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform