SQL Server 101 – How to Round Up or Round Down a Number ?

In SQL Server, you may want to round up or round down a number to find the ceiling or floor value. You can use the CEILING and FLOOR function in SQL Server to achieve this.

How to Round Up or Round Down a Number in SQL Server?

Here’s a SQL query that demonstrates the usage of ROUND,CEILING and FLOOR function in SQL server.

DECLARE @input decimal(18,5)
SET @input = 78.78912
SELECT CEILING(@input) CeilingValue
SELECT FLOOR(@input) FloorValue
SELECT ROUND(@input, 2) RoundValue
SQL Server 101 - How to Round Up or Round Down a Number ?

In the above query , we were successfully be able to use the CEILING and FLOOR function to get the rounded up or rounded down value. Remember that the CEILING function and FLOOR is very different from the ROUND function as the ROUND function uses the rounding(ceiling/floor) function under the hood.

Copy link
Powered by Social Snap