Syntax
ABS(expr)
Purpose
The ABS function returns the absolute value of an expression. The return value has the same data type as the numeric expression.
ABS supports comparison operations, returning a BOOL value that is then converted to a numeric type. The result is 1 (TRUE) or 0 (FALSE).
If the input is NULL, the return value is NULL.
If the input is a string of pure numbers, it is automatically converted to a numeric type. The return value is 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
