Beginner

59. ABS Function

Learn how to return the absolute value of a number using SQL.

📘 Lesson 59 of 728 ⏱ 6 min 🎯 Beginner

The ABS function returns the absolute value of a numeric expression. An absolute value represents the magnitude of a number without its negative sign. For example, ABS(-500) returns 500.

In business analysis, the direction of a difference may sometimes be less important than its size. ABS can help measure the magnitude of a variance or difference.

If the difference between expected and actual sales is -5000, ABS can return 5000 to show the size of the variance.

SQL
SELECT
    ABS(ActualSales - TargetSales) AS SalesVariance
FROM SalesPerformance;

ABS is useful for variance analysis, financial reconciliation, error measurement, forecasting comparisons, and performance analysis.

  • ABS returns an absolute numeric value.
  • Negative values become positive.
  • Positive values remain positive.
  • ABS is useful for variance analysis.
  • ABS works with numeric expressions.
What does ABS do in SQL?

ABS returns the absolute value of a numeric expression.

What does ABS(-500) return?

ABS(-500) returns 500.

Have you finished this lesson?

Introduction to SQL – All Lessons