Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing Trailing Zeros from Decimal Value 1

Status
Not open for further replies.

larrydavid

Programmer
Jul 22, 2010
174
US
Hello,

In my SELECT statement I have the following:

Code:
[Open_Rate_Current] = isnull(ROUND(Open_Rate_Current / 1000000,2),0),

The output of which is:

Code:
0.77000000

I have been researching and trying several approaches towards getting the output to display as follows:

Code:
0.77

This is not turning out to be a trivial task as I thought it might be. I thought there might be a straightfoward way to approach this. If someone could please show me how to do this I would greatly appreciate it.

Thanks,
Larry
 

You can convert to decimal, but pay attention to the precision digits specified in the decimal declaration. Scale will be '2' for two digits to the right of the decimal point:

Code:
select [Open_Rate_Current] = convert(decimal(6,2), isnull(ROUND(@Open_Rate_Current / 1000000.0,2),0))


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Thanks Mark. I've been playing around with this and am able to get where i need to be. Much obliged.

Thanks,
Larry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top