Skip to main content

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 example
SELECT SIGN(10.3)
-- 1.0
Return the sign of a negative number
SELECT SIGN(-5.2)
-- -1.0
Return NULL for a NULL input
SELECT SIGN(NULL)
-- null

SIGN(numeric_expression int32) → int32​

  • numeric_expression: Input expression.

Examples

SIGN example
SELECT SIGN(-5)
-- -1
Return the sign of zero
SELECT SIGN(0)
-- 0

SIGN(numeric_expression int64) → int64​

  • numeric_expression: Input expression.

Examples

SIGN example
SELECT SIGN(24)
-- 1

SIGN(numeric_expression float) → float​

  • numeric_expression: Input expression.

Examples

SIGN example
SELECT 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.