語法
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.?
返回數(shù)字X,截斷到D小數(shù)位。 如果D為0,結(jié)果沒有小數(shù)點或小數(shù)部分。 D是負(fù)數(shù),導(dǎo)致值X的小數(shù)點左邊的D數(shù)字變?yōu)榱恪?/br>
實例
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
本文摘自 :https://blog.51cto.com/u