Declaration
SIGN(X)
Description
SIGN(X) returns the sign of the parameter, which depends on whether X is negative, zero, or positive. It supports floating-point and hexadecimal numbers. The return value is:
Negative value:
-1Zero value:
0Positive value:
1
This function supports comparison operations. The result is converted to a numeric type and processed, generating a value of 1 (TRUE) or 0 (FALSE).
If NULL is input, 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