ABS

The ABS function returns the absolute value of a number.

Read syntax diagram
>>-ABS(numeric-expression)-------------------------------------><

The schema is SYSIBM.

The argument must be an expression that returns a value of any built-in numeric data type.

Start of changeThe arguments can also be a character string or graphic string data type. The string input is implicitly cast to a numeric value of DECFLOAT(34).End of change

The result of the function has the same data type and length attribute as the argument.

The result can be null; if the argument is null, the result is the null value.

ABSVAL can be specified as a synonym for ABS. DB2® supports this keyword to provide compatibility with previous releases.

Example: Assume that host variable PROFIT is a large integer with a value of -50000. The following statement returns a large integer with a value of 50000.
   SELECT ABS(:PROFIT)
     FROM SYSIBM.SYSDUMMY1;