Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select when less than n occurances
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Divers
Thread ID:
00991781
Message ID:
00991785
Vues:
16
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform