Search code examples
sql-serverexcelsql-server-2005

How to perform Excel ROUNDUP function in SQL Server 2005


Hi how can we do Excel ROUNDUP function in SQL Server 2005 ?

Below is my test case:

In Excel:

=ROUNDUP(1/100,0)*0.25 = 1

=ROUNDUP(10/100,0)*0.25 = 1

In SQL Server 2005:

SELECT (ROUND(CAST(1 AS decimal(18,4))/100,0)) = 0.0000

which is really diffirent.

Thanks and Regards


Solution

  •  select ceiling(round(5.0/2.0,0.25)*0.25) --1
    
     select floor(round(5.0/2.0,0.25)*0.25) --0
    

    Ceiling

    Floor