Purpose
You can call this function to return the sign of the given number. The sign is 1, -1, or 0.
Syntax
SIGN(numeric_expression)
Parameters
numeric_expression is of a numeric data type such as NUMBER, FLOAT, BINARY_FLOAT, or BINARY_DOUBLE or any data type that can be implicitly converted to a numeric data type.
Return type
The return type is NUMBER.
If
numeric_expression > 0, the function returns1.If
numeric_expression < 0, the function returns-1.If
numeric_expression = 0, the function returns0.
Examples
The following example returns the signs of 2, -2, 0, and 3+3.
obclient> SELECT SIGN(2),SIGN(-2),SIGN(0),SIGN(3+3) FROM DUAL;
+---------+----------+---------+-----------+
SIGN(2) SIGN(-2) SIGN(0) SIGN(3+3)
+---------+----------+---------+-----------+
1 -1 0 1
+---------+----------+---------+-----------+
1 row in set