Skip to main content
Version: V1.4.0

ABS

Declaration​

ABS(expr)

Description​

The ABS function returns the absolute value of an expression. The return value has the same data type as the numeric expression.

The function supports comparison operations. The result is a BOOL value, which is 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.

Example​

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 (0.001 sec)