MySQL sign()函數
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)