Page 1 of 1

fields calculated in sum and division of decimals

Posted: 2020-11-18 12:29
by lramirez
good morning
Can somebody help me...
I am adding 4 values and that total divided by 4
ex: 80.00 90.00 79.50 85.10 / 4 = 83.650000
I can't get it to just return two decimal places and make it look like this: 83.65

THANKS FOR ANY HELP

SELECT SUM(`f_academica`.`pro1`+`f_academica`.`pro2`+`f_academica`.`pro3`+`f_academica`.`pro4`) DIV(4) FROM `f_academica`
WHERE `f_academica`.`id`='%ID%'
TOTAL:83

AND

SELECT SUM(`f_academica`.`pro1`+`f_academica`.`pro2`+`f_academica`.`pro3`+`f_academica`.`pro4`) /4 FROM `f_academica`
WHERE `f_academica`.`id`='%ID%'
TOTAL:83.650000

I need 83.65 :)

THANKS FOR ANY HELP

Re: fields calculated in sum and division of decimals

Posted: 2020-11-18 13:19
by pbottcher
Hi,

use

Code: Select all

ROUND(SUM(`f_academica`.`pro1`+`f_academica`.`pro2`+`f_academica`.`pro3`+`f_academica`.`pro4`) /4,2)

Re: fields calculated in sum and division of decimals

Posted: 2020-11-18 13:25
by lramirez
yeah
Thank you very much for the help
... today I learned more ...