您好,欢迎来到爱若养生。
搜索
您的当前位置:首页函数:MySQL中取整函数round和floor_MySQL

函数:MySQL中取整函数round和floor_MySQL

来源:爱若养生


bitsCN.com

函数:MySQL中取整函数round和floor

示例:

 round(123.456,2) ------------ 123.47ROUND ( numeric_expression , length [ , function ] ) 

参数

numeric_expression

精确数字或近似数字数据类型类别的表达式(bit 数据类型除外)。

length

是 numeric_expression 将要四舍五入的精度。length 必须是 tinyint、smallint 或int。当 length 为正数时,numeric_expression 四舍五入为 length 所指定的小数位数。当 length 为负数时,numeric_expression 则按 length 所指定的在小数点的左边四舍五入。

function

是要执行的操作类型。function 必须是 tinyint、smallint 或 int。如果省略 function 或 function 的值为 0(默认),numeric_expression 将四舍五入。当指定 0 以外的值时,将截断 numeric_expression。

round(123.456, 0) ------- 123.000 SELECT FLOOR(123.45), FLOOR(-123.45), FLOOR($123.45) --------- --------- ----------- 123 -124 123.0000 SELECT CEILING(123.45), CEILING(-123.45), CEILING(0.0) 

以下

Copyright © 2019- areg.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务