Purpose
ABS() returns the absolute value of numeric_expression. It converts negative numbers to positive numbers and does not affect zeros and positive numbers.
Syntax
ABS(numeric_expression)
Parameters
| Parameter | Description |
|---|---|
| numeric_expression | An expression of an exact or approximate numeric data type, such as NUMBER, FLOAT, BINARY_FLOAT, or BINARY_DOUBLE. |
Return type
The return type is the same as the data type of numeric_expression.
Examples
The following example returns the absolute values of -1.0, 0.0, 6.66, and (3-6).
obclient> SELECT ABS(-1.0), ABS(0), ABS(6.66), ABS(3-6) FROM DUAL;
+-----------+--------+-----------+----------+
| ABS(-1.0) | ABS(0) | ABS(6.66) | ABS(3-6) |
+-----------+--------+-----------+----------+
| 1 | 0 | 6.66 | 3 |
+-----------+--------+-----------+----------+
1 row in set