Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 problems with round()

Author  Topic 

kagenohikari8
Starting Member

2 Posts

Posted - 2008-02-19 : 09:54:56
I understand that when you use ROUND(8.5,1), I would get 9 but no matter how hard I try, I get 8.

I had this code that suppose to get the round of a quotient. I wanted to update a number of records by converting them via multiplication and/or division.

Here:

UPDATE Length
SET inchTOcm = inchTOcm*2.5, metricTOton = ROUND(metricTOton/1.1,1);

supposing the original value of inchTOcm are in inch and in metricTOton are in metric ton.

There is a value in the metricTOton that when I divide it with 1.1, it's 345.81818. However, when I round it, it displays 345 instead of 346.

Is there wrong? How can I do this without using the CASE statement?

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-02-19 : 09:58:25
It's not ROUND(8.5,1), you will have to use ROUND(8.5, 0) to get 9.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

kagenohikari8
Starting Member

2 Posts

Posted - 2008-02-19 : 10:01:18
oh.

now I get it. >_>

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-19 : 10:01:59
See how ROUND() works

http://doc.ddart.net/mssql/sql70/ra-rz_20.htm
Go to Top of Page
   

- Advertisement -