Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to get counts in returned recordset
Message
De
13/07/2004 07:45:32
Erick Miranda
Formata Data Business - Grupo Linx
Contagem, Brésil
 
 
À
13/07/2004 06:29:39
Steven Kleypas
Tarrant County College District
Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00923610
Message ID:
00923625
Vues:
23
Hi Steven!

>I want a list of courses with the number of students who pass and fail each one. The following is what I am working with, but am having no luck getting correct numbers for the nPass and nFail vars. Would anyone have a suggestion?
>SELECT Courses.ctitle,Courses.tstartdate, ;
>       Courses.csectnum, Courses.iid,;
>  COUNT(students.cstatus = "PASS" ) AS nPass,;
>  COUNT(students.cstatus = "FAIL" ) AS nFail;
> FROM  regman!courses INNER JOIN regman!students ;
>   ON  Courses.iid = Students.icourseid;
> GROUP BY Courses.csectnum;
> ORDER BY Courses.tstartdate

I think that one way is you to do 2 select's, thus:
* Student -> PASS
SELECT Courses.ctitle,Courses.tstartdate, ;
       Courses.csectnum, Courses.iid,;
  COUNT(students.cstatus) AS nPass,;
 FROM  regman!courses INNER JOIN regman!students ;
   ON  Courses.iid = Students.icourseid;
 Where students.cstatus = "PASS" ;
 GROUP BY Courses.csectnum;
 ORDER BY Courses.tstartdate

* Student -> FAIL
SELECT Courses.ctitle,Courses.tstartdate, ;
       Courses.csectnum, Courses.iid,;
  COUNT(students.cstatus) AS nFail,;
 FROM  regman!courses INNER JOIN regman!students ;
   ON  Courses.iid = Students.icourseid;
 Where students.cstatus = "FAIL" ;
 GROUP BY Courses.csectnum;
 ORDER BY Courses.tstartdate
Maybe other way woulde you to do Sub-Select in you Select statement, but I think that is only possible in VFP8 or VFP9.
I hope this help you.
Erick
Força Sempre!
Strength Always!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform