Declaration
ABS(expr)
Description
Absolute value function. It returns the absolute value of an expression. The return type of the function is the same as the data type of the numeric expression.
Comparison operations are supported, with the result being a BOOL value. This value is converted to a numeric type, resulting in 1 (TRUE) or 0 (FALSE).
If NULL is input, the return value is NULL.
If a string of only digits is input, it can be automatically converted to a numeric type. The return value will be converted to a BIGINT.
Examples
obclient> SELECT ABS(5), ABS(-5.777), ABS(0), ABS(1/2), ABS(1-5);
+--------+-------------+--------+----------+----------+
| ABS(5) | ABS(-5.777) | ABS(0) | ABS(1/2) | ABS(1-5) |
+--------+-------------+--------+----------+----------+
| 5 | 5.777 | 0 | 0.5000 | 4 |
+--------+-------------+--------+----------+----------+
1 row in set