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:
00991790
Vues:
21
Ken,

Try this way
* Get all custid hat occurs less than 10 times 
SELECT custid ;
	FROM orders ;
	GROUP BY custid ;
	HAVING CNT(*) < 10 ;
	INTO CURSOR crsLessThan10

SET ORDER TO custid IN orders 

SCAN
	SELECT orders
	SCAN WHILE custid = crsLessThan10.custid
		* Do processing
	ENDSCAN 
ENDSCAN
>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?
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform