SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 convert sql 'int' value to 2 decial places
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

kieran5405
Yak Posting Veteran

Ireland
92 Posts

Posted - 08/28/2006 :  10:45:41  Show Profile
Hi,

I have a column of type int.

In the column i have the value 6696...for example. I select it in a select statement and divide by 100...this brings back 66.

I want to convert it to decimal (or whatever is the most appropiate) and return the proper value which is 66.96.

I have been using the below hacked together statement (which works) but it keeps putting trailing zeros after the 2 digits to the right of the decimal place. I want the figure to only 2 decimal places as thats all there ever will be. Is there a neater way to do this.

SELECT Convert(Decimal(10,2),(SUM(NormalHours)))/100 as 'TotalNormalHours'
FROM
Wages


Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

USA
7020 Posts

Posted - 08/28/2006 :  10:56:04  Show Profile

SELECT
	convert(decimal(10,2),SUM(NormalHours)*.0100)
	as [TotalNormalHours]
FROM
	Wages




CODO ERGO SUM
Go to Top of Page

kieran5405
Yak Posting Veteran

Ireland
92 Posts

Posted - 08/28/2006 :  11:13:17  Show Profile
cheers...
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000