我想给学生评分,所以需要除以topper达到的最高分是各个学科。一旦我想除以最小也没有。我不想做多个查询。
这是桌子
id name physics math
1 Adam 68 80
2 Mark 55 97
3 Luis 78 44
4 Philip 99 62
5 James 59 89
我的PHP代码是
$re99 = "SELECT * FROM `tableA` order by id desc limit 10";
while($row2 = $res2->fetch_assoc()){
$name=$row2['name'];
$physics=$row2['physics'];
$math=$row2['math'];
$grade=$physics/99+$math/97;
$poor='poor performer in math is mark with 55 marks and Luis with 44 marks';
}
我不知道如何在一个查询中从上表获取这4个值(99,97,55,44)
关于什么 select *, max(physics) as high_physics, max(math) as high_math, min(physics) as min_physics, min(math) as min_math from tableA order by id desc limit 10;
然后你可以做类似的事情 $grade = $physics / $row2['high_physics'] + $math / $row2['high_math'];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句