This tutorial explains how to use the MySQL ABS function with syntax and examples.
The MySQL ABS function returns the absolute value of a number.
The syntax for the ABS function in MySQL is:
ABS( number )
The number to convert to an absolute value.
The ABS function can be used in the following versions of MySQL:
Let's look at some MySQL ABS function examples and explore how to use the ABS function in MySQL.
For example:
mysql> SELECT ABS(-23);
Output: 23
mysql> SELECT ABS(-23.6);
Output: 23.6
mysql> SELECT ABS(-23.65);
Output: 23.65
mysql> SELECT ABS(23.65);
Output: 23.65
mysql> SELECT ABS(30 * -1);
Output: 30