Beginner

294. FLOOR Function

Learn how to round a number downward to the nearest integer.

📘 Lesson 294 of 728 ⏱ 9 min 🎯 Beginner

The FLOOR function returns the largest integer that is less than or equal to the supplied numeric expression.

Rounding downward is useful when calculations should count only complete units or when values must remain within a lower limit.

Calculate the number of complete boxes available from an inventory quantity.

SQL
SELECT
    ProductID,
    AvailableUnits,
    FLOOR(AvailableUnits / 10.0) AS CompleteBoxes
FROM Inventory;

FLOOR is useful in inventory planning, packaging, capacity calculations, pricing, and operational analysis.

  • FLOOR rounds downward.
  • It returns the largest integer less than or equal to the value.
  • It is useful for complete-unit calculations.
  • It can be used with decimal values.
  • Behavior for negative numbers should be understood carefully.
What does FLOOR do?

FLOOR returns the largest integer that is less than or equal to the supplied number.

How is FLOOR different from CEILING?

FLOOR rounds toward the lower integer while CEILING rounds toward the higher integer.

Have you finished this lesson?

Introduction to SQL – All Lessons