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:
00345657
Views:
14
OOPS!

Don't use the keyword total as a field name in the Select statement - if I'd been writing the query in the VFP IDE, the blue field name wolud have made my error obvious - sorry.

Cheers,

Andrew


>Dennis,
>
>You can use
>
SELECT color, count(*) as total ;
>   FROM (yourtable) ;
>   GROUP BY color
>to get the sub totals, and then
>
SELECT "all" as color, count(*) as total ;
>   FROM (yourtable)
>to get all of the colours. If you're careful with the literal in the second select, you colud even UNION the clauses.
>
>Cheers,
>
>Andrew
>

>>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...
>>
>>Thanks,
>>
>>Dennis


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Previous
Reply
Map
View

Click here to load this message in the networking platform