mysql - How to take out percentage in sql -


i have sql students attendance table have entered values this:

student_id total_classes class_attended 1          31            26  2          31            21 3          31            17 4          31            21 5          31            29 

i want calculate attendance percentage of student_id 1. im looking how frame sql statement above..

you need divide number of attended classes total , multiply 100:

select student_id, round(class_attended/total_classes*100) total student 

the above return following result:

+------------+-------+ | student_id | total | +------------+-------+ |          1 |    84 | |          2 |    68 | |          3 |    55 | |          4 |    68 | |          5 |    94 | +------------+-------+ 

Comments

Popular posts from this blog

java - unable show chart in xls document using jasper reports -

javascript - How to change image src on success AJAX -

java.lang.RuntimeException: Could not generate dummy secret at sun.security.ssl.RSAClientKeyExchange.<init> -