SQL SIGN() function returns the sign of a number.
SQL SIGN() is a built-in function used for returning the sign of the number. It indicates whether the number is positive or negative by returning the following result: –
- 1 if the number is positive i.e., number>0
- -1 if the number is negative i.e., number<0
- 0 is the number is zero i.e., number=0
SELECT SIGN (number);
Number: The number which is used for testing its sign.
Select Sign (-23);
As the number is less than 0. So, the sign of the number returned was -1.
Select Sign (0);
As the number is equal to 0. So, the sign of the number was returned was 0.
Select Sign (1);
As the number is greater than 0. So, the sign of the number returned was 1.
Select Sign (0.1);
As the number is greater than 0 and is in decimal format. The number returned is also in decimal format.
Select Sign (40-50);
Here, the arithmetic expression is executed in sign function which resulted in a number less than 0. So, the sign of the number is negative.
Select Sign (NULL);
As the number NULL is given as an input to the function. So, NULL was returned as an output.