Skip to content
SQLSimplified
numeric

ABS()

Returns the absolute (non-negative) value of a number.

Description

ABS returns the absolute value of a number — its distance from zero, always non-negative. Negative numbers become positive; positive numbers and zero stay the same. It's useful for measuring magnitude regardless of direction, like the size of a budget variance.

Syntax

ABS(expression)

Parameters

NameDescriptionOptional
expressionA numeric column or expression.No

Return Type

Returns the same numeric type as the input (INT stays INT, DOUBLE stays DOUBLE).

Examples

Employees & Departments

Loading database engine...

Employees & Departments

Loading database engine...

Use it for differences

ABS(a - b) gives the size of the gap between two values without caring which is larger.

Common Mistakes

  • Expecting a sign. ABS always returns a non-negative number; it doesn't tell you the original direction.
  • Applying to text. It needs a number; passing a string errors or coerces unexpectedly.

See also: SIGN, ROUND.

Search

Search lessons, functions, examples, and practice problems