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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query rounds off percentages, would like actual numbers 1

Status
Not open for further replies.

beetlebailey

Programmer
Jan 4, 2005
51
US
The following query rounds off the percentage to the closest whole number like: 96.00% I would like to see the actual value like: 95.59% Any ideas please ?

cast(sum(Hour1)/(cast(Tact1 as decimal(6,2))) as decimal(6,2))*100 as Percent1

SQL 2000, Windows 2000 Pro SP4

Thank you....
 
Try this:
Code:
select cast(sum(22)/cast(19 as decimal(6,2)) * 100 as decimal(6,2)) as Percent1

Regards,
AA
 
Also do the multiplication first before dividing to get rid of loosing precision

SELECT 100.0 * sum(Hour1) / Tact1 AS Percent1

Zhavic


---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
The original poster wants the output only until 2 decimal places.

Regards,
AA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top