Categories: Math
SIGN
Returns the sign of the input expression: 1 for positive, -1 for negative, 0 for zero. Returns NULL if the input is NULL.
Syntax
SIGN(numeric_expression double) → double
- numeric_expression: Input expression.
Examples
SIGN exampleSELECT SIGN(10.3)
-- 1.0
SELECT SIGN(-5.2)
-- -1.0
SELECT SIGN(NULL)
-- null
SIGN(numeric_expression int32) → int32
- numeric_expression: Input expression.
Examples
SIGN exampleSELECT SIGN(-5)
-- -1
SELECT SIGN(0)
-- 0
SIGN(numeric_expression int64) → int64
- numeric_expression: Input expression.
Examples
SIGN exampleSELECT SIGN(24)
-- 1
SIGN(numeric_expression float) → float
- numeric_expression: Input expression.
Examples
SIGN exampleSELECT SIGN(0.0)
-- 0
Usage Notes
1 is returned if the input expression is positive. -1 is returned if the input expression is negative. 0 is returned if the input expression is 0.