ID EN
Mathematical Functions

ABS(X)

MySQL 8.4

Returns the absolute value of X, or NULL if X is NULL.

Syntax

MYSQL
SELECT ABS(2);
2
SELECT ABS(-32);
32

Examples

Example

The result type is derived from the argument type. An implication of this is that ABS(-9223372036854775808) produces an error because the result cannot be stored in a signed BIGINT value.

MYSQL
SELECT ABS(2);
2
SELECT ABS(-32);
32