Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to round off decimal value like below:-

1.01-1.50 ---As Result 1.00
1.51-2.00 ---As Result 2.00
Posted

Try:
SQL
SELECT ROUND(MyColumn - 0.01, 0) FROM MyTable
(You need the subtraction, otherwise 1.50 is rounded to 2.00)
 
Share this answer
 
Comments
Advay Pandya 13-Aug-15 5:29am    
Great advise for 1.50..... 5ed
Arasappan 13-Aug-15 14:14pm    
What is mean by 5ed
Hi Dinesh,

You can use "Round" function to round off the values.

Please refer below example of the rounding.

SQL
DECLARE @Num DECIMAL(18,2) = 1.4
SELECT ROUND(@Num,0)


Please let me know if you have any concern or query on this.

Thanks
 
Share this answer
 
SQL
SELECT ROUND(columnname,0) AS RoundedPrice
FROM tablename;
 
Share this answer
 
Usually, rounding is done this way:
1.00 <= X < 1.50 -> 1.00
1.50 <= X < 2.00 -> 2.00

If you don't have a round function, you can round to nearest integer with this formula:
Rounded= Int ( X + 0.5 )

Nearest cent
Rounded= Int ( X * 100 + 0.5 ) / 100

for rounding starting at 0.51:
Rounded= Int ( X + 0.49 )

The round function in modern languages is hiding details, but works the same.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900