Beginner

300. SIGN Function

Learn how to determine whether a numeric value is negative, zero, or positive.

📘 Lesson 300 of 728 ⏱ 9 min 🎯 Beginner

The SIGN function returns an indicator showing whether a numeric expression is negative, zero, or positive. The exact returned values depend on the database implementation, commonly -1, 0, and 1.

SIGN provides a simple way to classify numeric differences according to their direction.

Identify whether sales variance is negative, zero, or positive.

SQL
SELECT
    EmployeeID,
    ActualSales - TargetSales AS Variance,
    SIGN(ActualSales - TargetSales) AS VarianceDirection
FROM EmployeeSales;

SIGN is useful for variance analysis, financial monitoring, exception reporting, and classification of numeric changes.

  • SIGN identifies the direction of a number.
  • Negative values are commonly represented by -1.
  • Zero is commonly represented by 0.
  • Positive values are commonly represented by 1.
  • It is useful for variance classification.
What does SIGN return?

SIGN returns an indicator showing whether a numeric expression is negative, zero, or positive.

How can SIGN help with variance analysis?

SIGN can quickly classify whether a variance is below, equal to, or above zero.

Have you finished this lesson?

Introduction to SQL – All Lessons