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:
00557400
Vues:
8
This message has been marked as the solution to the initial question of the thread.
You have to get total number of people first and than use it in your select
SELECT 0
USE f:\okul_win\okul2
COUNT TO lnTotal

select sex, count(*), ROUND(count(*)/lnTotal * 100,2) AS Percent ;
  from okul2 ;
  group by sex;
  order by sex;
  into curs mycurs
>i have like this SQL syntax
>
>select sex,count(sex) from okul2 ;
>group by sex;
>order by sex;
>into curs mycurs
>brow
>use in mycurs
>
>and it shows in browse mode
>
>sex cnt_sex
>M 12
>W 5
>
>but i want to calculate percentage of M W counts of total records
>
>total records =17
>M=12/17=0,71
>M=5/17=0,29
>
>it must show in browse mode
>
>sex cnt_sex percentage
>M 12 0,71
>W 5 0,29
>
>but how ?
>
>thanks for the help
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform