What is ABS() in SQL?

The ABS() function returns the absolute value of a number.

Figure 1 shows a mathematical representation of the ABS() function.

Figure 1: Mathematical representation of ABS() function

Syntax

ABS(number)

Parameter

The ABS() function takes a number as a parameter.

Return value

The ABS() function returns the absolute value of a number that is passed in as a parameter.

Code

-- negative number
SELECT ABS(-10);
-- 0
SELECT ABS(0);
-- positive number
SELECT ABS(10);
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources