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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Round a float?

Author  Topic 

raisor
Starting Member

28 Posts

Posted - 2004-11-24 : 08:28:59
Hello everyone,

I have a 'priceOriginal' field that is float, it has prices stored such as 51.99 etc. etc.
Now I need to create a 10% discount of it all to another float field called price.

I'm trying to accomplish this by doing:
UPDATE products
SET price = ROUND(priceOriginal - priceOriginal * .1, 0)

It works, but I receive results such as:
priceOriginal: 45.99
And then the price becomes
price: 41

Even though I want it to become: 41.39 (rounded 41.391 to two digits after the dot)

How can I accomplish this?

Thank you very much!

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-11-24 : 08:39:32
UPDATE products
SET price = ROUND(priceOriginal - (priceOriginal * .1), 2)
Go to Top of Page

raisor
Starting Member

28 Posts

Posted - 2004-11-24 : 08:46:40
ehm......


'Silence'




I was close though ;)
Geeeez, that was stupid!, well thank you very much! :D
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-11-25 : 02:40:08
or you could

UPDATE products
SET price = ROUND(priceOriginal * .9, 2)


--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -