The ABS function returns the absolute value of a number.
ABS changes all numbers to positive values.
ABS has no effect on zero values.
This example returns the absolute values for the input numbers.
SELECT ABS(-15.6) AS '-15.6',
ABS(0.4) AS '0.4',
ABS(-8.91) AS '-8.91'
| -15.6 | 0.4 | -8.91 |
|---|---|---|
| 15.6 | 0.4 | 8.91 |
Syntax of the ABS function.
ABS(number)
number -- a number to convert to an absolute value.