我需要找到分数(学生成绩)。它工作正常,但它只选择7个最佳分数出现在结果表上。我有两个问题:
此查询适用于单个学生,如何获得全班学生的成绩?
SELECT sum(( case when((test+exam)/2)>=75 then 1 when ((test+exam)/2)>=65 then 2 when ((test+exam)/2)>=45 then 3 when ((test+exam)/2)>=30 then 4 when ((test+exam)/2)<30 then 5 END)) as points
FROM (SELECT test,exam FROM results u
WHERE regno='$regno' and term='$term' and form='$form' and year='$year' ORDER BY ((test+exam)/2) DESC LIMIT 0,7)k;