Friday, March 30, 2012

How to control number precision?

Hi all,
There is a table like this:
item quantity
-
A 1
B 3
C 7
D 6
Now I want to get a table like this:
item Percent
-
A 1/17
B 3/17
C 7/17
D 6/17
For script:
select item,
quantity/sum(quantity)
from table
but the number has a very long precision, like 0.0588235456456, I only want to keep two number after the point as like 0.06,what should I do?
Thanks!

Coeus:

Maybe something like:

select convert (numeric (9,2), 0.0588235456456)

|||

Thanks for help. :)

I also can use round(variable, 2).

No comments:

Post a Comment