MySQL Mathematical Functions(数学方法)

NameDescription例子
ABS(X)绝对值SELECT ABS(-32); # -> 32
ACOS(X)反余弦SELECT ACOS(1); # -> 0
ASIN(X)反正弦SELECT ASIN(0.2); # -> 0.20135792079033
ATAN(X)反正切SELECT ATAN(2); # -> 1.1071487177941
ATAN2(), ATAN()Return the arc tangent of the two arguments
CEIL(X)CEILING()
CEILING(X)向上取整SELECT CEILING(1.23); # -> 2
CONV(N,from_base,to_base)Convert numbers between different number bases
COS(X)余弦SELECT COS(PI()); # -> -1
COT()Return the cotangent
CRC32()Compute a cyclic redundancy check value
DEGREES(X)Convert radians to degreesSELECT DEGREES(PI()); # -> 180
EXP(X)指数SELECT EXP(2); # -> 7.3890560989307
FLOOR()向下取整SELECT FLOOR(1.23), FLOOR(-1.23); # -> 1, -2
LN(X)Return the natural logarithm of the argumentSELECT LN(2); # -> 0.69314718055995
LOG()Return the natural logarithm of the first argumentSELECT LOG(10,100); # -> 2
LOG10()Return the base-10 logarithm of the argument
LOG2()Return the base-2 logarithm of the argument
MOD(N,M), N % M, N MOD MReturn the remainderSELECT MOD(234, 10); # -> 4
PI()Return the value of piSELECT PI(); # -> 3.141593
POW()Return the argument raised to the specified powerSELECT POW(2,2); # -> 4
POWER()POW()
RADIANS()Return argument converted to radians
RAND([N])随机数SELECT FLOOR(7 + (RAND() * 5));
ROUND(X), ROUND(X,D)随机数SELECT ROUND(-1.23); # -> -1
SIGN(X)大于0的判定为1,小于0的返回-1,0等于0SELECT SIGN(-32);
SIN(X)Return the sine of the argument
SQRT(X)Return the square root of the argumentSELECT SQRT(4); # -> 2
TAN()Return the tangent of the argument
TRUNCATE(X,D)Truncate to specified number of decimal placesSELECT TRUNCATE(-1.999,1); # -> 100

参考:
https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值