Dofactory.com
Dofactory.com
Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

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



Last updated on Dec 21, 2023

Earn income with your data and sql skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.