The SQL ABS function calculates the absolute value of a number or the result of an expression that evaluates to a number.
Syntax #
ABS (number | expression)
Code language: SQL (Structured Query Language) (sql)
Arguments #
number | expression
Number or expression that evaluates to a number.
Return Type #
ABS returns the same data type as its argument.
Examples #
The following statement calculates the absolute value of -100:
SELECT abs(-100);
abs ------- 100 (1 row)
The following example shows how to calculate the absolute value of an expression:
select abs (100-300);
abs ------- 200 (1 row)
Was this tutorial helpful ?