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.
Author |
Topic |
faijurrahuman
Starting Member
15 Posts |
Posted - 2012-02-28 : 06:47:17
|
Hi ;I want to round the last two numbers , below my queryDECLARE @N floatset @N=(SELECT CONVERT(numeric,(493-1)) / 493 *100)PRINT @NResult 99.7971Expected Result99.80DECLARE @a FloatSET @a=(select CONVERT(numeric,(24625- 1 ))/24625 *100)PRINT @aResult99.9959Expected Result99.99In this two cases are solve the problems. any one help this problemsShare Knowledge team |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2012-02-28 : 07:00:57
|
Have you tried the ROUND() function?You second result should round up as it is over halfway towards the next whole number, is there any reason to round down? |
 |
|
faijurrahuman
Starting Member
15 Posts |
Posted - 2012-02-28 : 07:11:34
|
yes ...Share Knowledge team |
 |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-02-28 : 07:25:17
|
You can use round function, but there are some caveats you need to be aware of, discussed in this thread: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=158176For your example: DECLARE @N floatset @N=(SELECT CONVERT(numeric,(493-1)) / 493 *100)PRINT ROUND(@N,2)DECLARE @a FloatSET @a=(select CONVERT(numeric,(24625- 1 ))/24625 *100)PRINT ROUND(@a,2,1) |
 |
|
|
|
|