Returns the sign of a numeric value: -1 for negative values, 0 for zero, and 1 for positive values.
Syntax
Parameters
| Parameter | Description | Supported input types |
|---|
<value> | The value whose sign is returned. | DOUBLE PRECISION, REAL, INTEGER, BIGINT, NUMERIC |
Return Type
Same type as the input <value>.
SIGN(NULL) returns NULL.
SIGN('NaN'::DOUBLE PRECISION) returns 0, matching PostgreSQL semantics — NaN is neither positive nor negative.
SIGN('Infinity'::DOUBLE PRECISION) returns 1.
SIGN('-Infinity'::DOUBLE PRECISION) returns -1.
Example
The following example returns the sign of several values:
| negative double | zero int | positive int |
|---|
| -1 | 0 | 1 |
Rows: 1Execution time: 2.30ms