December 19, 2001 06:19 PM

Returning a Percentage of 2 Summed Values

Rating: (0)
SQL Server Magazine
InstantDoc ID #23235

I'm trying to use T-SQL to return the relative percentage of two summed values when I divide the values into each other, but I always get 0. Here's an example of the type of calculation I'm trying:

SELECT
((SUM(Parts.Scrap) / SUM(Parts.Produced))*100) 
AS Per_Scrap
FROM
Parts

Both the Scrap and Produced columns are defined as int data types in the Parts table. My calculation behaves almost as if the division operation is doing integer math. What am I doing wrong?

...

...This article is for paid Professional Members only.

Already a Professional Member? Please log in now:

NOT A PROFESSIONAL MEMBER? YOU CHOOSE:

Professional Membership

Monthly

Annual

VIP Membership

Monthly

Annual

Add a Comment

There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here
GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS