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
| Name | Description | Optional |
|---|---|---|
| expression | A 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.
ABSalways 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.
Related Functions
See also: SIGN, ROUND.