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.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 convert sql 'int' value to 2 decial places

Author  Topic 

kieran5405
Yak Posting Veteran

96 Posts

Posted - 2006-08-28 : 10:45:41
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)

7020 Posts

Posted - 2006-08-28 : 10:56:04
[code]
SELECT
convert(decimal(10,2),SUM(NormalHours)*.0100)
as [TotalNormalHours]
FROM
Wages


[/code]

CODO ERGO SUM
Go to Top of Page

kieran5405
Yak Posting Veteran

96 Posts

Posted - 2006-08-28 : 11:13:17
cheers...
Go to Top of Page
   

- Advertisement -