Beginner

258. MOD Function

Learn how to find the remainder after dividing one number by another.

📘 Lesson 258 of 728 ⏱ 8 min 🎯 Intermediate

The MOD operation returns the remainder left after dividing one numeric value by another.

Remainders are useful for identifying even and odd numbers, creating cycles, and applying repeating business rules.

Identify whether employee IDs are even or odd.

SQL
SELECT
    EmployeeID,
    MOD(EmployeeID, 2) AS Remainder
FROM Employees;

MOD is useful in scheduling, grouping, alternating logic, validation, and periodic calculations.

  • MOD returns a division remainder.
  • It is useful for even and odd checks.
  • It can create repeating patterns.
  • The syntax varies between databases.
  • The divisor should not be zero.
What does MOD return?

MOD returns the remainder after dividing one number by another.

How can MOD identify even numbers?

If MOD(number, 2) returns zero, the number is even.

Have you finished this lesson?

Introduction to SQL – All Lessons