SQL ABS Function

Savigo
You organize your data. Now organize your savings.
Set savings goals, track your progress, and stay on course.
Get Savigo for iPhone 

In SQL, The ABS function calculates the absolute value of a number or the result of an expression that evaluates to a number.

Syntax #

ABS (number | expression)

Arguments #

number | expression
Number or expression that evaluates to a number.

Return Type #

The ABS function returns the same data type as its argument.

Examples #

The following statement uses the ABS function to get the absolute value of -100:

SELECT ABS(-100);

Try it

Output:

abs
-------
100

The following example uses the ABS function to calculate the absolute value of an expression:

SELECT
  ABS(100 -300);

Try it

Output:

abs
-------
200

Summary #

  • Use the SQL ABS function to get the absolute value of number.

Was this helpful?