Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Efficient counting of recs with duplicate key fields
Message
From
13/06/1999 19:54:04
 
 
To
13/06/1999 13:01:34
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00229225
Message ID:
00229304
Views:
17
>SEEK vVal TAG KeyTagName
>COUNT TO nDupes WHILE keyfield = vVal
>
>This doesn't mess up your index order, is optimizable (well, that depends on your key expression), and should be faster as it doesn't create a cursor.
>

If you mean that a completely different tag order is active, I'm not sure why the above works, since records having keyname=vVal would not necessarily be >contiguous< with respect to the ordering by another key, and the WHILE would fail before all dups are encountered.

If the above really does work when ordered by a completely different key I'd have to say that the WHILE clause is a little counterintuitive. Substituting FOR for WHILE fixes it, I think?!

What I was really trying to figure out is whether "searching by filtering" buys you anything or hurts you if you have a big file. The following:

SET FILTER TO keyfield=vVAL
COUNT ALL

seems pretty sexy to me, but I'm aware that underlying implementation can sometimes take all the fun out of 'clever' solutions! That's why I asked the question in the first place.
"The Iron Fish: The water is cold...but the fish don't mind"
...Jay Jenks, boyhood chum
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform