Tutorial Gateway

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

MySQL ABS Function

by suresh

MySQL ABS function is one of the Numeric Functions, which is beneficial to return the absolute positive value of the specified expression. In this article, we show how to find Absolute Values in MySQL using Command Prompt and Workbench with example.

MySQL ABS Syntax

The basic syntax of the ABS in MySQL is as shown below:

SELECT ABS (Numeric_Expression)
FROM Source

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

MySQL ABS Function 1

MySQL ABS Function Example 1

The ABS Function returns the positive value of any numeric value. The following MySQL query shows multiple ways to use the ABS function.

-- MySQL ABS Function Example

-- Numeric Value
SELECT ABS(-52) AS `Absolute Value`;

-- Absolute Value of Numeric Expression
SELECT ABS(10 + 35 - 102) AS `Absolute Value`;

-- Absolute Value of string value
SELECT ABS('-10.02') AS `Absolute Value`;

-- Absolute Value of String
SELECT ABS('MySQL') AS `Absolute Value`;

In the below statement, We used the ABS function to find the absolute value of different values. Here, we assigned a new name to the result as ‘Absolute Value’ using the ALIAS Column in MySQL.

MySQL ABS Function 2

MySQL ABS Example 2

The MySQL ABS Numeric Function also allows you to find the absolute value of the data in a column. In this example, we are going to find the absolute values for all the records present in the ServiceGrade column.

-- MySQL Absolute Values Example
USE mysqltutorial;
SELECT Product, Color,
		StandardCost, Sales, TaxAmt, 
        ServiceGrade,
        ABS(ServiceGrade) AS `Absolute Value`
FROM `numeric functions`;

MySQL ABS Function 3

Placed 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
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy