Beginner

252. CEILING Function

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

📘 Lesson 252 of 728 ⏱ 8 min 🎯 Beginner

The CEILING function returns the smallest integer that is greater than or equal to a numeric value.

Business calculations sometimes require values to be rounded upward, especially when calculating quantities, capacity, or required resources.

Calculate the number of full boxes required to store products when each box holds a fixed number of items.

SQL
SELECT
    ProductName,
    CEILING(Quantity / 10.0) AS RequiredBoxes
FROM Inventory;

CEILING is useful in inventory planning, packaging, capacity planning, billing, and resource calculations.

  • CEILING rounds upward.
  • It returns an integer in common use.
  • Values already at an integer remain unchanged.
  • It is useful for capacity calculations.
  • Function naming can vary by database.
What does CEILING do?

CEILING returns the smallest integer greater than or equal to the supplied number.

Why use CEILING in inventory calculations?

It ensures enough complete units, such as boxes or packages, are counted when partial quantities are not practical.

Have you finished this lesson?

Introduction to SQL – All Lessons