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)
 Trailing zeroes..

Author  Topic 

kristine
Starting Member

25 Posts

Posted - 2006-08-07 : 01:42:23
hi..

how can i round off trailing zeroes from the result of dividing float values?..like round it off to two decimal places only..

thanx!:)

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-07 : 01:45:09
use round()
or user convert() to convert it to 2 decimal places like decimal(10,2)


KH

Go to Top of Page

kristine
Starting Member

25 Posts

Posted - 2006-08-07 : 01:50:48
can u please tell me its proper syntax?..what if like it's a quotient or product of some formula..how can i manage rounding it off to two decimal places only..

example..select (price*discount) as actual_price from pricelist

..how can i do transform the actual price into a rounded-2-decimal places only..
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-07 : 01:55:26
[code]select convert(decimal(12,2), price*discount) as actual_price from pricelist

select round(price*discount, 2) as actual_price from pricelist
[/code]


KH

Go to Top of Page

kristine
Starting Member

25 Posts

Posted - 2006-08-07 : 02:03:44
thanx a bunch..^_^
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-07 : 08:36:40
Also read about Convert and Cast functions in sql server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kristine
Starting Member

25 Posts

Posted - 2006-08-09 : 21:47:50
yeah thanx..i have and i did..but i didn't get it so i run into the forums..the help in here is much easier to understand and the people so far are very accommodating and helpful..

thanx anyway:)
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-09 : 22:04:07
quote:
Originally posted by kristine

yeah thanx..i have and i did..but i didn't get it so i run into the forums..the help in here is much easier to understand and the people so far are very accommodating and helpful..

thanx anyway:)



You should just run a simple test in Query Analyzer when you have questions like this. Especially since SQL Server Books Online usually has a number of simple examples that you can just copy and paste.







CODO ERGO SUM
Go to Top of Page
   

- Advertisement -