Estoy calculando un promedio desde una consulta en mysql, pero al realizar el calculo manual no siempre calcula bien el promedio y el error me lo da por un decimal, he comprobado el calculo desde php con la libreria fpdf y de forma manual. Les adjunto la consulta:
Código MySQL:
Ver original `nota`.
`upclass_id` AS `upclass_id`, `c`.
`class_name` AS `class_name`, `nota`.
`cal_id` AS `cal_id`, sum((`nota`.
`grade` * `rc`.
`weightings`)) / (select sum(`rule_comment`.
`weightings`) `rule_comment`
(`rule_comment`.
`actives` = 'true')) AS `promedio`, `nota`.
`student_id` AS `student_id` ((((((`student_subject_grade` `nota`
join `rule_comment` `rc`) ((`nota`.`subject_id` = `sub`.`id`)
and (`sub`.
`sy_id` = `s`.
`id`) and (`rc`.
`subject_id` = `sub`.
`id`) and (`nota`.
`cal_id` = `cal`.
`id`) and (`cal`.
`active` = 'true') and (`cal`.
`release_cal` = 'true') and (`c`.
`id` = `nota`.
`upclass_id`) and (`g`.
`id` = `c`.
`grade_id`)) group by `cal`.
`id` , `nota`.
`student_id` order by `nota`.
`student_id` , `cal`.
`id`
[/PHP]
Tambien lo he probado redondeando el promedio con la funcion ROUND(n,2) y siempre el mismo resultado.