Open In App

SIGN() Function in MySQL

Last Updated : 28 Sep, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
SIGN() function in MySQL is used to return the sign of the given number. It returns 1 if the number is positive, -1 if the number is negative and 0 for zero. Syntax :
 
SIGN(X)
Parameter : SIGN() function accepts one parameter as input and will give you the results in values like Positive(+1),Negative(-1) and Zero(0).
  • X -A number whose sign we want to check.
Returns - It returns the value of sign of the given number i.e. Positive(+1), Negative(-1) and Zero(0). Example-1 : Applying SIGN() function to Zero.
SELECT SIGN(0) AS Sign_Val;
Output :
Sign_Val 
0
Example-2 : Applying SIGN() function to a positive number.
SELECT SIGN(12) AS Sign_Val;
Output :
Sign_Val 
1
Example-3 : Applying SIGN() function to a negative number.
SELECT SIGN(-2) AS Sign_Val;
Sign_Val
-1
Example-4 : Applying SIGN() function to a numeric column in a table. Table -Number
X
+12
1.8
0
-1.8
-14
SELECT X, SIGN(X) AS X_Sign  FROM Number;
Output :
XX_Sign
121
1.81
00
-1.8-1
-14-1

Next Article
Article Tags :

Similar Reads