miércoles, agosto 10, 2016

Redondeo Arriba en MySQL

CREATE DEFINER=`admin`@`%` FUNCTION `Round_UP`(NumToRound double, NumDec integer) RETURNS double
BEGIN
return CEIL(NumToRound * pow(10,NumDec)) /pow(10,NumDec);
END

select round(10.3843,2), truncate(10.3843,2),Round_Up(10.3843,2);

# round(10.3843,2), truncate(10.3843,2), Round_Up(10.3843,2)
10.38, 10.38, 10.39

No hay comentarios.: