SIGN
The SIGN function is used to determine the sign of a number. It takes one argument, which must be of the FLOAT type. The result will be of the INTEGER type and can be -1, 0, or 1.
Syntax
SIGN(number)
Examples
- Using the 
SIGNfunction with integers: 
SELECT SIGN(2) AS SIGN1, 
       SIGN(-2) AS SIGN2, 
       SIGN(+2) AS SIGN3;
-- Result: 1, -1, 1
- Using the 
SIGNfunction with floats: 
SELECT SIGN(2.0) AS SIGN1, 
       SIGN(-2.0) AS SIGN2, 
       SIGN(+2.0) AS SIGN3;
-- Result: 1, -1, 1
- Using the 
SIGNfunction with zero: 
SELECT SIGN(0.0) AS SIGN1, 
       SIGN(-0.0) AS SIGN2, 
       SIGN(+0.0) AS SIGN3;
-- Result: 0, 0, 0
- Using the 
SIGNfunction with NULL: 
SELECT SIGN(NULL) AS sign;
-- Result: NULL
Error Cases
- The 
SIGNfunction requires the argument to be of FLOAT type: 
SELECT SIGN('string') AS SIGN;
-- Error: FunctionRequiresFloatValue("SIGN")
SELECT SIGN(TRUE) AS sign;
-- Error: FunctionRequiresFloatValue("SIGN")
SELECT SIGN(FALSE) AS sign;
-- Error: FunctionRequiresFloatValue("SIGN")
- The 
SIGNfunction takes exactly one argument: 
SELECT SIGN('string', 'string2') AS SIGN;
-- Error: FunctionArgsLengthNotMatching("SIGN", 1, 2)