SIGN(X)
这个函数返回X的符号(负数,零或正)对应-1,0或1。
mysql>SELECT SIGN(-4.65); +---------------------------------------------------------+ | SIGN(-4.65) | +---------------------------------------------------------+ | -1 | +---------------------------------------------------------+ 1 row in set (0.00 sec) mysql>SELECT SIGN(0); +---------------------------------------------------------+ | SIGN(0) | +---------------------------------------------------------+ | 0 | +---------------------------------------------------------+ 1 row in set (0.00 sec) mysql>SELECT SIGN(4.65); +---------------------------------------------------------+ | SIGN(4.65) | +---------------------------------------------------------+ | 1 | +---------------------------------------------------------+ 1 row in set (0.00 sec)