Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Question
Message
De
07/07/1999 23:17:57
 
 
À
07/07/1999 14:05:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00238418
Message ID:
00238662
Vues:
15
1. Create a table Ranges:
Group Min Max
1     6   10
2     11  15
3     16  20
etc
2. SELECT CustNo, count(*) AS PurchaseCount FROM MyTable INTO MyCursor GROUP BY CustNo

3. SELECT Ranges.Group, Ranges.Min, Ranges.Max, Count(*) FROM MyCursor, Ranges
WHERE MyCursor.PurchaseCount >= Ranges.Min AND MyCursor.PurchaseCount <= Ranges.Max GROUP BY Ranges.Group

Vlad

>Is there an "easy" way (using 'group by' or similar) to get a count of records in a range from a table?
>
>Example, suppose you have a simple table with one field for a customer number. Evey time the customer purchases something, they get a new entry in this table. Now it's easy to get a count for each customer of how many purchases they made, however - what if I want a "range count" - that is - a listing of how many customers made 1-5 purchases, how many made 6-10 purchases, 11-15, 16-20 and so on? Is there a way to wrap all this up in a single SQL statement?
>
>thanks,
>Ken
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform