Mega Code Archive

 
Categories / MySQL Tutorial / Math Numeric Functions
 

SIGN(X) returns the sign of the argument as -1, 0, or 1, depending on whether X is negative, zero, or positive

mysql> mysql> SELECT SIGN(-32); +-----------+ | SIGN(-32) | +-----------+ |        -1 | +-----------+ 1 row in set (0.00 sec) mysql> mysql> SELECT SIGN(0); +---------+ | SIGN(0) | +---------+ |       0 | +---------+ 1 row in set (0.00 sec) mysql> mysql> SELECT SIGN(234); +-----------+ | SIGN(234) | +-----------+ |         1 | +-----------+ 1 row in set (0.00 sec) mysql>