SIGN
The SIGN function takes a single argument, which can be any numeric data type such as INTEGER, FLOAT, or DECIMAL, and returns a value of -1, 0, or 1, depending on the sign of the input argument.
Syntax
SELECT SIGN(expr);
Arguments
Parameter |
Description |
|---|---|
|
Numeric data types |
Return
The SIGN function returns the same data type as inserted, with the exception of REAL, which is converted to DOUBLE.
Depending on the sign of the input argument, the return is:
-1, if the input expression is negative
0, if the input expression is zero
1, if the input expression is positive
Example
SELECT SIGN(-10), SIGN(0), SIGN(5) ;
Output:
sign | sign0 | sign1
-----+------+-------
-1 | 0 | 1