SQL CEILING Function

CEILING rounds to the nearest integer greater than the input value.

To round to the nearest integer that is smaller use the FLOOR function.

Alternatively, use the ROUND function.

Example

#

This example return the nearest integer that is greater than the input value.

SELECT CEILING(35.4) AS Ceiling
Result:  1 record
Ceiling
36

Syntax

Syntax of the CEILING function.

CEILING(value)

value -- a number, variable, or column name.

More Examples

CEILING on a column

PRODUCT
Id
ProductName
SupplierId
UnitPrice
Package
IsDiscontinued
Problem: List products with prices that are rounded upwards to the nearest dollar. Sort by price.
SELECT ProductName, UnitPrice,
       CEILING(UnitPrice) AS Ceiling
  FROM Product
 ORDER BY UnitPrice
Result:  78 records
ProductName UnitPrice Ceiling
Geitost 2.50 3
Guaraná Fantástica 4.50 5
Konbu 6.00 6
Filo Mix 7.00 7
Tourtière 7.45 8
Rhönbräu Klosterbier 7.75 8

You may also like



Guides


vsn 3.1