ABS
The ABS function returns the absolute value of Expression.
SQL syntax
ABS(Expression)Parameters
ABS has the parameter:
| Parameter | Description |
|---|---|
|
|
Operand or column can be any numeric data type. Absolute value of |
Description
-
If
Expressionis of typeNUMBER, the data type returned isNUMBERwith maximum precision and scale. Otherwise,ABSreturns the same data type as the numeric data type ofExpression. -
If the value of
ExpressionisNULL,NULLis returned. If the value of theExpressionis-INF,INFis returned.
Examples
Create table abstest and define columns with type BINARY_FLOAT and TT_INTEGER. Insert values -BINARY_FLOAT_INFINITY and -10. Call ABS to return the absolute value. You see INF and 10 are the returned values:
Command> CREATE TABLE abstest (col1 BINARY_FLOAT, col2 TT_INTEGER);
Command> INSERT INTO abstest
VALUES (-BINARY_FLOAT_INFINITY, -10);
1 row inserted.
Command> SELECT ABS (col1) FROM abstest;
< INF >
1 row found.
Command> SELECT ABS (col2) FROM abstest;
< 10 >
1 row found.