Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting most recent orders?
Message
 
 
À
11/09/2008 14:56:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01249462
Message ID:
01346783
Vues:
7
>>Use Orders.OrderDate IS NULL to make it SQL Server compatible :)
>>
>>>
SELECT Customer.CustomerID, Customer.CustName, Orders.OrderID, ;
>>>			Orders.OrderDate, Orders.Destination ;
>>>	FROM Customer ;
>>>		LEFT OUTER JOIN orders ON Orders.CustomerID = Customer.CustomerID ;
>>>	WHERE ISNULL(OrderDate) OR OrderDate = ( SELECT MAX(OrderDate) FROM Orders Recent WHERE Recent.CustomerID = Orders.CustomerID) 
>>>
>>>
>>>
>VFP changed it to IS NULL anyways. Unfortunately, I'd previously tried OR IS NULL, and VFP 8.1 comes back with "SQL expression is too complex" Error 1845. Using Sys(3055, 2040) still returns the error.

If you're using VFP8 move WHERE TO JOIN condition as Sergey suggested. Otherwise I would recommend the other query or add customers without orders with UNION. In my tests (see the whole thread) using derived table technique was faster than the way Sergey showed.
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform