我想根据下表根据他们的观察得出的学生排名。假设任何学生在班上的得分最高,但他/她在任何一门学科上均不及格,则不应考虑其排名。
1。表名称为“ resultdata”
满分为(1000)
及格分数是33
ID | subject ID | subject | fullmarks | obtmarks |passmarks
1 | 1 | HINDI | 100 | 80 | 33
2 | 2 | ENGLISH | 100 | 90 | 33
3 | 3 | MATHEMATICS | 100 | 76 | 33
4 | 4 | SOCIAL SCIENCE| 100 | 69 | 33
也喜欢其他主题。
2。表格名称为“结果”
ID|result | student |student|mother |father |class|term/ |rollno|section|
|date | ID |name |name |name | |semester | | |
1 |11.09.2019| 1 |Jasmine|Eliana |Ritesh | 8 |1st Term | 10 | A |
2 |11.09.2019| 2 |Kiyas |Fanny |Rajnish| 10 |1st Term | 1 | B |
3 |11.09.2019| 3 |Ena |Rashmi |Prakash| 9 |1st Term | 12 | C |
4 |11.09.2019| 4 |Sunaina|Ankita |Chander| 7 |1st Term | 15 | A |
5 |11.09.2019| 5 |Ankit |Sujata |Roy | 8 |1st Term | 11 | B |
6 |11.09.2019| 6 |Krishna|Bala |Gopal | 8 |1st Term | 5 | C |
7 |11.09.2019| 7 |Ranga |Hima |Hitesh | 9 |1st Term | 7 | A |
8 |11.09.2019| 8 |Suraj |Priya |Hemal | 7 |1st Term | 10 | B |
9 |11.09.2019| 9 |Saurabh|Archana|Suyog | 10 |1st Term | 9 | B |
3。表格名称为“主题”
ID | subject | fullmarks | passmarks
1 | HINDI | 100 | 33
2 | ENGLISH | 100 | 33
3 | MATHEMATICS | 100 | 33
4 | SOCIAL SCIENCE | 100 | 33
5 | Computer | 50 | 20
也喜欢其他主题。
主题表的ID与resultdata表的subjectID有关系。
如何使用公式或vba代码解决此问题?
我在查询中尝试了此公式,但是它不起作用:
Rank: DCount("*","resultdata","[fullmarks]>" & [obtmarks])+1
答案 0 :(得分:1)
如果您不想包括成绩不及格的学生,请进行初步查询以消除他们。然后使用该查询对其余学生进行排名。考虑:
查询1:通过
SELECT resultdata.StudentID, Sum(resultdata.obtmarks) AS SumOfobtmarks
FROM resultdata
GROUP BY resultdata.StudentID
HAVING resultdata.StudentID Not In (SELECT resultdata.StudentID
FROM resultdata
WHERE resultdata.obtmarks<[passmarks]);
Query2:
SELECT Passing.SumOfobtmarks, Passing.StudentID,
(SELECT Count(*) FROM Passing AS T1 WHERE T1.SumOfobtmarks > Passing.SumOfobtmarks)+1 AS Rank
FROM Passing
ORDER BY Passing.SumOfobtmarks DESC;
但是,如果多个学生的分数相同,则结果可能不会令人满意。这是带有许多示例的常见主题。一则评论http://allenbrowne.com/ranking.html。最佳解决方案可能是涉及“临时”表的解决方案,如艾伦的文章所述。或尝试使用Lebans Serialize函数,链接在Allen的文章中。另一个展示这些技术http://www.mendipdatasystems.co.uk/rank-order-queries/4594424063的优秀教程。