Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Counting field values in a table....
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00345652
Message ID:
00345658
Views:
13
>I need to count the number of occurrences of certain field values...
>
>i.e.
>
>field ... color
>
>I need to get a count of records with values red, green, blue, etc.
>
>then a total of all records...
>
>I found a cube function which works with sql server but foxpro doesn't seem to like it...
>
>Is there another way to do this in foxpro...
You could use the following:
select color, count(*) as Color_Cnt from mytable group by color into cursor c_temp
If you don't have any deleted records in your table, you could use reccount('mytable'). If you have deleted records, just perform another query on the results of the first query:
select sum(color_cnt) from c_temp into array latemp
latemp[1] will hold the total of all the counted colors.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform