0Pricing
SQL Academy · Lesson

Useful Math Functions

ABS, MOD, POWER and more.

Why Math Functions Matter

SQL is not just about storing and retrieving text — it is also a powerful tool for numeric calculations. Built-in math functions let you compute absolute values, remainders, powers, and more, all without leaving your query.

In this lesson you will learn the most useful numeric functions in SQL: ABS, MOD, POWER, SQRT, ROUND, CEIL, FLOOR, and SIGN.

ABS — Absolute Value

ABS(n) returns the absolute (non-negative) value of a number. Negative numbers become positive; positive numbers and zero are unchanged.

This is handy when you care about the distance from zero rather than the direction — for example, calculating how far a temperature is from the target, regardless of whether it is above or below.

SELECT ABS(-42),  -- 42
       ABS(15),   -- 15
       ABS(0);    -- 0

All lessons in this course

  1. Arithmetic and Operators
  2. Rounding and Truncating
  3. Integer vs Decimal Division
  4. Useful Math Functions
← Back to SQL Academy