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

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -