Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to select TOP 1 in a LEFT JOIN?
Message
 
 
To
29/07/2005 09:43:21
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
Database:
MS SQL Server
Miscellaneous
Thread ID:
01036783
Message ID:
01036944
Views:
10
>
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform