Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select when less than n occurances
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00991781
Message ID:
00991785
Views:
17
>Ok here's one for you guys, I want to split out from a table all records where a certain field's value occurs less than say 10 times in the said table.
>
>so say the field is custid and my table is orders, I could get out ALL the customers that have made less than 10 orders.
>
>The table is already in that field value order, so currently I scan through counting and checking if it changes, at that point and if my count is less than my limit I skip back and mark those records, reset the count and then continue the scan.
>
>this is not particularly fast or tidy yet I can't think of a better way, anyone?
>
>Ken.

What about:
select custid, count(*) as occurrences from orders group by custid having occurences < 10 into cursor c_orders
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform