sign function
The sign
function returns the sign of the specified expression, that is, zero if the argument is zero, 1 if the argument is greater than zero, and -1 if the argument is less than zero.
Syntax:
double sign(n)
Semantics:
- n: The argument n is an expression that resolves to a number.
- return type: double.
- Returns 1.0 if n resolves to a positive number.
- Returns -1.0 if n resolves to a negative number.
- Returns 0.0 if n resolves to zero.
- Returns a NULL value in the following cases:
- n resolves to a NULL value
- n does not resolve to a number
- Returns NaN if n resolves to NaN.
Example:
SELECT sign(n) FROM PHtable