SQL SIGN Function

The SIGN function returns the sign of the specified number.

If the value is greater than 0, it returns 1, and if less than 0, it returns -1.

If the value is 0, then SIGN returns 0 as well.

Example

#

This example returns the signs of the specified numbers.

SELECT SIGN(32.81) AS '32.81',
       SIGN(32) AS '32',
       SIGN(0) AS '0',
       SIGN(-32) AS '-32',
       SIGN(-32.81) AS '-32.81'
Result:  1 record
32.81 32 0 -32 -32.81
1.00 1 0 -1 -1.00

Note: The number of decimals returned is the same as in the input number.


Syntax

Syntax of the SIGN function.

SIGN(value)

value -- a number or column name.


You may also like



Guides


vsn 3.1