Tutorial Gateway

  • C
  • C#
  • Python
  • SQL
  • Java
  • JS
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs
  • MySQL

MySQL SIGN Function

MySQL SIGN function is one of the Numeric Functions, which is to return the sign of the specified expression. And the return value is either Positive (+1), Negative (-1), or Zero (0). The basic syntax of the SIGN in MySQL is as shown below:

SELECT SIGN (Numeric_Expression)
FROM Source
  • If the Expression is Zero, the SIGN function returns Zero as a result.
  • If the Numeric_Expression is Negative Number, it returns Negative One(-1) as a result.
  • And If the Expression is positive Number, the SIGN function returns Positive One(+1).

To demonstrate this MySQL SIGN Numeric function, we are going to use the below shown data

MySQL SIGN Function 1

MySQL SIGN Function Example 1

The MySQL SIGN finds and returns the sign of a specified value. The following query shows multiple ways to use the SIGN function.

-- MySQL SIGN Function Example

-- Finding Sign for Negative Value
SELECT SIGN(-240.75) AS `Sign Value`;

-- Finding Sign for Positive Value
SELECT SIGN(125.267) AS `Sign Value`;

-- Finding Sign for Zero
SELECT SIGN(0) AS `Sign Value`;

-- Sign of string value
SELECT SIGN('125.274') AS `Sign Value`;

-- Sign Example on String
SELECT SIGN('MySQL') AS `Sign Value`;

-- Sign Example on NULLs
SELECT SIGN('NULL') AS `Sign Value`;

From the screenshot below, you can see that we used SIGN function on different values.

MySQL SIGN Function Example 1

and

MySQL SIGN Function Example 2

MySQL SIGN Example 2

The MySQL SIGN Numeric also allows you to check the sign value for the column data. In this example, we are going to find the sign value for all the records present in the Service Grade column.

-- MySQL SIGN Function Example
USE mysqltutorial;
SELECT Product, Color,
		StandardCost, Sales, TaxAmt,
        ServiceGrade,
        SIGN(ServiceGrade) AS `Grade Sign`
FROM `numeric functions`;
MySQL SIGN Function Example 3

Filed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions

Copyright © 2021· All Rights Reserved by Suresh.
About | Contact | Privacy Policy