The ABS function returns the absolute value of a numeric expression, removing its negative sign while preserving its magnitude.
Absolute values are useful when the direction of a difference is not important and only the size of the difference matters.
Calculate the absolute difference between actual sales and target sales.
SELECT
EmployeeID,
ABS(ActualSales - TargetSales) AS SalesVariance
FROM EmployeeSales;
ABS is useful in financial variance analysis, error calculations, distance calculations, and performance reporting.
- ABS returns a non-negative value.
- Negative values become positive.
- Positive values remain unchanged.
- Zero remains zero.
- It is useful for variance analysis.
What does ABS do?
ABS returns the absolute value of a numeric expression.
Where is ABS commonly used?
ABS is commonly used for calculating absolute differences, variances, and error amounts.