Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculating percentage of records with SQL
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00557394
Message ID:
00557759
Views:
10
It only works if you don't have deleted records in the table.

>This might run very slowly, but I it seems to work:
>
>SELECT SEX, count(sex) as iGroupCt, ;
> (COUNT(*) / RECCOUNT() * 100) AS nPct FROM folks ;
> GROUP BY sex ;
> ORDER BY nPct DESC
>
>You might store RECCOUNT() to a variable before the SQL-SELECT to avoid taking that hit:
>
>liRecCount = RECCOUNT()
>SELECT SEX, count(sex) as iGroupCt, ;
> (COUNT(*) / liRecCount * 100) AS nPct FROM folks ;
> GROUP BY sex ;
> ORDER BY nPct DESC
< SNIP >
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform