Beginner

211. MOD Function

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

📘 Lesson 211 of 728 ⏱ 8 min 🎯 Beginner

The MOD operation returns the remainder left after one number is divided by another. Different database systems may use MOD() or the % operator.

Remainders are useful for identifying even and odd numbers, repeating patterns, and grouping records based on numeric cycles.

Identify employees whose EmployeeID is an even number.

SQL
SELECT
    EmployeeID,
    EmployeeName
FROM Employees
WHERE MOD(EmployeeID, 2) = 0;

MOD is useful for scheduling, alternating groups, batch processing, record partitioning, and numeric validation.

  • MOD returns the remainder of division.
  • MOD can identify even and odd numbers.
  • Syntax varies between database systems.
  • The % operator is supported by some databases.
  • It is useful for repeating numeric patterns.
What does MOD do?

MOD returns the remainder after one number is divided by another.

How can MOD identify even numbers?

Divide the number by 2 and check whether the remainder is zero.

Have you finished this lesson?

Introduction to SQL – All Lessons