Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Always trips me up!
Message
From
14/06/2007 17:41:43
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01233129
Message ID:
01233332
Views:
27
>>Vladimir's suggestion assumed that you have a PK in the child table (not that in proper design you didn't have one).
>
>Yes, and you should always have one. When I was translating that code into Mike's structure I made a typo using wrong key.
>
>BTW, Vladimir Maximov put this nicely into FAQ, but he told me that the idea originates from Igor Korolev.
>So, they both deserve a credit.
>
>BTW, I just used it recently myself the first time
>
>* Idea by Igor Korolev
>SELECT * from curInvoice1 cI ;
>WHERE cI.KyInvoice IN ;
>(SELECT CTOBIN(RIGHT(MAX(PADL(Inv_amount,20,'0')+BINTOC(KyInvoice)),4)) ;
>  			FROM curInvoice1 GROUP BY CheckNum) ;
>ORDER BY cI.CheckNum  INTO CURSOR curInvoice
>
>I needed to pick up one invoice with the maximum amount in case we have several invoices.

For that kind of query I am pretty sure that my suggestion (with complex derived table) will be faster.
That is because (JUST MY OPINION, NOT NEED TO BE TRUE AT ALL)
Because SQL starts from smaller result set and go to the biggest. WHERE clause is executed for every record.
That is why I prefer JOINS instead of WHERE (maybe I am completely wrong).
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform