mysql数学函数之truncate用法

隐身守侯 提交于 2019-11-30 12:04:14

语法
TRUNCATE(X,D)

Returns the number X, truncated to D decimal places. If D is 0, the result has no decimal point or fractional part. D can be negative to cause D digits left of the decimal point of the value X to become zero. 
返回数字X,截断到D小数位。 如果D为0,结果没有小数点或小数部分。 D是负数,导致值X的小数点左边的D数字变为零。
————————————————
 

 

 

 

SELECT truncate(1314.1314, 3);          # 1314.131
SELECT truncate(1314.1314, 1);          # 1314.1
SELECT truncate(1314.1314, 0);          # 1314
SELECT truncate(1314.1314, -1);         # 1310
SELECT truncate(1314.1314, -3);         # 1000
SELECT truncate(-1314.1314, -1);        # -1310
SELECT truncate(-1314.1314, -3);        # -1000
SELECT truncate(1314.1314*100, -3);     # 131000
1
————————————————
版权声明:本文为CSDN博主「刘鸿亮」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/csdn_0_001/article/details/79480699

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!