In this guide, we will explain how to use the MySQL ABS function with syntax and examples.
Description
The MySQL ABS function returns the absolute value of a number.
Syntax
The syntax for the ABS function is:
ABS( number )
Parameters or Arguments
number
The number to convert to an absolute value.
Applies To
The ABS function can be used in the following versions :
- MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23
Example
Let’s look at some ABS function examples and explore how to use the ABS function.
For example:
mysql> SELECT ABS(-23); Result: 23 mysql> SELECT ABS(-23.6); Result: 23.6 mysql> SELECT ABS(-23.65); Result: 23.65 mysql> SELECT ABS(23.65); Result: 23.65 mysql> SELECT ABS(30 * -1); Result: 30
Next Topic : Click Here
Pingback: MySQL: TRUNCATE Function | Adglob Infosystem Pvt Ltd