Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculating percentage of records with SQL
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00557394
Message ID:
00557759
Vues:
8
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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform