我有一个名为vw_results的表,其中包含特定学生的结果配置文件:
idNum |courseUnit | marks | Gpp | grade| id | semseterID | sessionName
06/021| 2 | 47 | 8 | B+ | 1 | 1 | 2010/11
06/021| 3 | 56 | 7 | C | 1 | 1 | 2010/11
. | 4 | 34 | 5 | C | 1 | 1 | 2010/11
. | 5 | 34 | 0 | F | 1 | 1 | 2010/11
. | 2 | 89 | 10 | A | 1 | 2 | 2010/11
. | 3 | 45 | 4 | D | 1 | 2 | 2010/11
. | 4 | 56 | 10 | C | 1 | 2 | 2010/11
. | 2 | 67 | 12 | B+ | 2 | 1 | 2011/12
. | 1 | 70 | 15 | A | 2 | 1 | 2011/12
. | 2 | 80 | 10 | A | 2 | 2 | 2011/12
. | 3 | 90 | 5 | A | 2 | 2 | 2011/12
计算GPA
"SELECT SUM( vwr.courseUnit ) cummUnit, SUM( vwr.GPP ) cummGPP, (
SUM( vwr.GPP ) / SUM( vwr.courseUnit ))cummGPA
FROM vw_result vwr
WHERE vwr.Grade NOT IN ('F') AND vwr.sessionID=".$_GET['sessionID']." AND vwr.semesterID=".$_GET['semesterID'].";"
如果$ _GET ['sessionID'] = 1且$ _GET ['semesterID'] = 2 那么
|cummGPA|
|1.913 |
如果$ _GET ['sessionID'] = 2且$ _GET ['semesterID'] = 1 然后
|cummGPA|
|2.730 |
如果$ _GET ['sessionID'] = 2且$ _GET ['semesterID'] = 2 那么
|cummGPA|
|2.774 |
关于如何解决这个问题的任何建议?! 谢谢!
答案 0 :(得分:0)
如果我理解你想要什么,那么它将是:
select count(id) from vw_results group by (id, semseterID) having (id=1 and semseterID=1) or (id=1 and semseterID=2) or (id=2 and semseterID=1) or (id=2 and semseterID=2)
希望它会起作用,从未尝试过。