SIGN()
Returns -1, 0, or 1 indicating the sign of a number.
Description
SIGN tells you the sign of a number: -1 for negative, 0 for zero, and 1
for positive. It's a quick way to bucket values into negative/zero/positive
without writing a CASE expression.
Syntax
SIGN(expression)Parameters
| Name | Description | Optional |
|---|---|---|
| expression | A numeric column or expression. | No |
Return Type
Returns an INTEGER (-1, 0, or 1).
Examples
Employees & Departments
Loading database engine...
Employees & Departments
Loading database engine...
Bucket with SIGN
CASE SIGN(x) WHEN -1 THEN 'neg' WHEN 0 THEN 'zero' ELSE 'pos' END is a tidy
way to label a value's direction.
Common Mistakes
- Expecting the magnitude.
SIGNreturns only -1/0/1, never the size of the number — useABSfor magnitude. - Applying to text. It needs a number.
- Confusing with comparison.
SIGN(x)is not a boolean; it's a category.
Related Functions
See also: ABS, ROUND.