Beginner

251. ABS Function

Learn how to return the absolute value of a number.

📘 Lesson 251 of 728 ⏱ 8 min 🎯 Beginner

The ABS function returns the absolute value of a numeric expression, converting negative values into their positive equivalent while leaving positive values unchanged.

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 expected and actual sales.

SQL
SELECT
    EmployeeName,
    ABS(TargetSales - ActualSales) AS SalesVariance
FROM EmployeeSales;

ABS is commonly used in variance analysis, financial reporting, reconciliation, error analysis, and performance measurement.

  • ABS returns an absolute value.
  • Negative values become positive.
  • Positive values remain unchanged.
  • Zero remains zero.
  • It is useful for variance calculations.
What does ABS do?

ABS returns the absolute value of a numeric expression.

Where is ABS commonly used?

ABS is commonly used for variance, difference, reconciliation, and error calculations.

Have you finished this lesson?

Introduction to SQL – All Lessons