我需要获得每个数组值的百分比值

时间:2017-05-01 11:19:04

标签: mysql

我有一张结果表。 其中的值存储如下。

table structure

如果学生从任何科目获得的成绩低于40%,我希望得到每个科目的百分比,这将显示状态失败。

如何做到这一点我尝试了百分比,但它显示了百分比。 我试过这样的

"SELECT *,
        avg( sub_marks * 100/sub_total_marks ) AS percentage,
        SUM(sub_marks)  as total,
        SUM(sub_total_marks)  as total_sub,
        GROUP_CONCAT(sub_marks SEPARATOR '</td><tr><tr><td>') sub_marks,
        GROUP_CONCAT(sub_total_marks SEPARATOR '</td><tr><tr><td>') sub_total_marks
FROM result r
JOIN students s
    ON r.std_id = s.student_id
JOIN adm_year a
    ON r.session_id = a.adm_y_id
JOIN class c
    ON r.class_id = c.c_id
JOIN levels l
    ON r.level_id = l.y_id
JOIN section x
    ON r.section_id = x.sec_id
WHERE exam_id = '$exam' AND
      session_id = '$session' AND
      class_id = '$class' AND
      level_id = '$level' AND
      section_id = '$section'
GROUP BY `std_id`"

1 个答案:

答案 0 :(得分:0)

我想要这样显示。想要获得每个主题的百分比

i want like this