Syntax
SIGN(X)
Purpose
SIGN(X) returns the sign of the parameter, which is determined by whether the value of X is negative, zero, or positive. It supports floating-point and hexadecimal numbers. The result is:
Negative value:
-1Zero value:
0Positive value:
1
This function supports comparison operations, and the result is converted to a numeric type, generating a result of 1 (TRUE) or 0 (FALSE).
If the input is NULL, the return value is NULL.
Examples
obclient> SELECT SIGN(-32), SIGN(0), SIGN(234);
+-----------+---------+-----------+
| SIGN(-32) | SIGN(0) | SIGN(234) |
+-----------+---------+-----------+
| -1 | 0 | 1 |
+-----------+---------+-----------+
1 row in set
obclient> SELECT SIGN(NULL),SIGN(FALSE),SIGN(0X01);
+------------+-------------+------------+
| SIGN(NULL) | SIGN(FALSE) | SIGN(0X01) |
+------------+-------------+------------+
| NULL | 0 | 1 |
+------------+-------------+------------+
1 row in set
