Earn income with your data and sql skills
We're building the largest freelancing marketplace for people like you.

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.

#

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.

CEILING on a column

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

Last updated on Dec 21, 2023

Earn income with your data and sql skills