ABS()

Description

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

Syntax

  1. > ABS(number)

Arguments

ArgumentsDescription
numberRequired. Any numeric data type supported now.

The result type is derived from the argument type.

Examples

  1. > drop table if exists t1;
  2. > create table t1(a int,b float);
  3. > insert into t1 values(1,-3.1416);
  4. > insert into t1 values(-1,1.57);
  5. > select abs(a),abs(b) from t1;
  6. +--------+--------+
  7. | abs(a) | abs(b) |
  8. +--------+--------+
  9. | 1 | 3.1416 |
  10. | 1 | 1.5700 |
  11. +--------+--------+