|
|
Question : Convert number to formatted string
|
|
This is a easy one (Can't for the life of me figure it out)
I want to convert a number to a string by rounding to one decimal place and and then appending a '%' to it, so for example 17.54732 => 17.55%
I had something like this : select convert(varchar,round(((12.13 - 10) / 12.13 ) * 100,1)) + '%'
but it returns: 17.6000000%
It should return 17.6%
|
Answer : Convert number to formatted string
|
|
round just rounds off to the specified numer of places ... it doesn't go on to "truncate" the actual result....
so
convert(varchar(11),convert(decimal(9,1),round(((12.13 - 10) / 12.13 ) * 100,1))) + '%'
|
|
|
|
|