Previous Next JavaScript must be enabled to correctly display this content

## 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 12-91 sign function

    SELECT sign(n) FROM PHtable

Value of n | Output
--- | ---
1.89 | 1.0
-1.89 | -1.0
0 | 0.0
sin(3*pi()/2) | -1.0