0

很多好人,任何帮助,请在 php 和 mysql 中是新的我有一个表“学生”,其中包含以下字段和密码。

id idnumber | Math | English | Geography | Ict | Biology
1  va01       100    80        89          100   82
2  va02       90     79        70          30    76
3  va03       100    100       100         100   90

有些事情让我堆积是如何通过php查询并从msql输出(平均,总,位置,出),结果假设按照高分来排列。例子:第一个学生是va03,第二个是va01,第三个是va02,假设是这样的

1: va03  math English Geograph Ict Biology  Average Total  out of
         100  100     100      100 90       98      490    3

2: va01  Math English Geograph Ict Biology  Average Total  out of
         90   79      70       80  76       79      395    3

3: va02  Math English Geograph Ict Biology  Average Total  out of
         90   79      70       30  76       69        345  3

先感谢您。

4

1 回答 1

0

我对 PHP 帮助不大,但是这方面的 SQL 应该相当简单..

Select idnumber, math, english, geography, ict, biology,
Average(math + english + geography + ict + biology)/5  as `mAverage`, 
(Select count(*) from student) as `out of `,
math + english + geography + ict + biology as `Total`
From student
Group by idnumber, math, english, geography, ict, biology
order by Average desc;
于 2013-10-30T01:41:20.850 回答