Skip to content
Tutorial Gateway
  • C
  • C#
  • Python
  • SQL
  • Java
  • JS
  • MySQL
  • 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
    • Search
MySQL SIGN Function Example 1

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 it is as shown below:

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

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

Source Table 1

MySQL SIGN Function Example

This method finds and returns the sign of a specified value. The following query shows multiple ways to use this.

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

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

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

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

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

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

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

Example 1

and

Example 2

The MySQL example of the Numeric method also allows you to check the 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.

SELECT Product, Color,
		StandardCost, Sales, TaxAmt,
        ServiceGrade,
        SIGN(ServiceGrade) AS `Grade Sign`
FROM `numeric functions`;
MySQL SIGN Function Example 3
Back to Categories MySQL
MySQL DEGREES Function
MySQL CEILING Function

Related Topics

  • MySQL Tutorial
  • How to Download
  • Install on Windows
  • Create Database
  • Delete Database
  • Create Table
  • Drop Table
  • SELECT Statement
  • ALIAS Column
  • Distinct
  • Insert Statement
  • Delete Statement
  • Truncate Table
  • WHERE Clause
  • Order By
  • Group By
  • Having Clause
  • LIMIT
  • Arithmetic Operators
  • COALESCE Function
  • AND Operator
  • NOT Operator
  • OR Operator
  • XOR Operator
  • BETWEEN Operator
  • Not Between Operator
  • GREATEST Function
  • LEAST Function
  • LIKE Operator
  • NOT LIKE Operator
  • IFNULL Operator
  • NULLIF Operator
  • INTERVAL Operator
  • IS Operator
  • IN Operator
  • NOT IN Operator
  • IS NOT NULL
  • IS NULL
  • Inner Join
  • Cross Join
  • Right Join
  • Left Join
  • Aggregate Functions
  • Date Functions
  • Date Function
  • String Functions
  • Numeric Functions
  Copyright © 2023. All Rights Reserved.
Home | About | Contact | Privacy Policy