Hemanth Komaravolu
Hemanth Komaravolu

Reputation: 29

SQL Server ROUND based on decimal values

How to to round the decimal values in SQL Server 2008 R2?

I need to round the value based on the decimal points.

Logic

If the decimal value greater than or equal to 0.5 then it should be rounded to the nearest upper number.

If the value is lesser than 0.5 then the value should be rounded to nearest lower number.

I can't use neither upper alone nor lower alone. It should be based on the value.

For example:

Upvotes: 2

Views: 936

Answers (2)

Dhaval
Dhaval

Reputation: 2379

Use round Function

 Example select convert(int,(ROUND(1.5,0)))
 o/p 2

For Info Please Refer This Link.......

http://technet.microsoft.com/en-us/library/ms175003%28v=sql.110%29.aspx

Upvotes: 1

Matt
Matt

Reputation: 15071

Use the ROUND function

SELECT ROUND(data) FROM table

Upvotes: 0

Related Questions