Forum Moderators: open

Message Too Old, No Replies

Help with percentage ?

         

mzeed

10:43 am on Sep 21, 2008 (gmt 0)

10+ Year Member



hi every body,

We have student marks in student table as follows:
Name marks
name1 8
name2 6
name3 8
name4 9
name5 8

How do we calculate the percentage as follows:
Students got 10: 0%
Students got 9: 15%
Students got 8: 70%

.. Etc.

Then calculate the proportion of success and failure:
Success rate: 80%
failure rate: 20%

any body have idea ?

Best Regards

RonPK

12:24 pm on Sep 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First query:
SELECT  
(SUM(IF(marks=10,1,0)) / COUNT(marks))*100 AS marks_10,
(SUM(IF(marks=9,1,0)) / COUNT(marks))*100 AS marks_9
FROM students

Second query:

SELECT  
(SUM(IF(marks>5,1,0)) / COUNT(marks))*100 AS success,
(SUM(IF(marks<6,1,0)) / COUNT(marks))*100 AS failure
FROM students