Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting most recent orders?
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01249462
Message ID:
01250761
Views:
14
>>>Try
>>>
>>>SELECT Customer.CustomerID, Customer.CustName, Orders.OrderID, ;
>>>			Orders.OrderDate, Orders.Destination ;
>>>	FROM Customer ;
>>>		INNER JOIN orders ON Orders.CustomerID = Customer.CustomerID ;
>>>	WHERE OrderDate = ( SELECT MAX(OrderDate) FROM Orders o2 WHERE o2.CustomerID = Orders.CustomerID)
>>>
>>
>>Hi Sergey,
>>
>>This select will return the same result (VFP9 only). I'm wondering which one is better?
>>
>>SELECT Customer.CustomerID, Customer.CustName, Orders.OrderID, ;
>>			Orders.OrderDate, Orders.Destination ;
>>	FROM Customer ;
>>		INNER JOIN orders ON Orders.CustomerID = Customer.CustomerID ;
>>         Inner JOIN (select Max(OrderDate) as Max_Date, CustomerID from Orders group by CustomerID) MaxOrders ;
>>on Orders.CustomerID = MaxOrders.CustomerID  and ;
>>Orders.OrderDate = MaxOrders.Max_Date
>
>Run tests and tell us.

Hi Sergey,

Thanks a lot for your response.

I thought you knew the answer on this question. Ok, I may try to run some tests.

Appreciate your help as always.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform