Solved

Percentage Calculation

Posted on 2010-11-08
5
382 Views
Last Modified: 2012-06-27
Pl. See Code Snippet1278892
Sql Server 2005

The result of a tsql is 

tmtr    aMtr    bMtrpercentage  years   months
----------------------------------------------
4431	4380	51	0.988490	2010	7
8946	8946	0	1.000000	2010	8
1179	1083	96	0.918575	2010	10
----    -----   ----
14556   14409   147
-----   -----   -----

1. Total of Tmtr is 14556
2. Total of Amtr is 14409
So the Percentage of Amtr is calculated as 14409/14556 = 98.99%

But why this do not reconcile with (0.9884+1.00+0.9185)/3 = 96.89%

The percentage difference is 2.10 

Why is there difference?

Open in new window

0
Comment
Question by:Mehram
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:raulggonzalez
Comment Utility
Because mathematically they are different....

You have to do the percentage of your totals, not the average of the partial amounts.


Cheers
0
 
LVL 8

Accepted Solution

by:
raulggonzalez earned 250 total points
Comment Utility
One graphic example


100 - 99  --> 0.99
 
200 - 199  --> 0.995
 
300 - 299  --> 0.99666666666666666666666666666667
 
            SUM / 3 --> 0,99388888888888888888888888888889

but the percentage of the sum is

600 - 150 --> 0,995



So, unfortunately they are different, maybe without decimals you can get the same result like

100 - 25 --> 0.25
200 - 50 --> 0.25
300 - 75 --> 0.25
                   sum / 3 = 0.25

600 - 150 -> 0.25


but playing with decimals... better calculate the percentage of the sum.


Cheers
0
 
LVL 8

Assisted Solution

by:lomo74
lomo74 earned 250 total points
Comment Utility
because (a+b+c) / (d+e+f) != ((a/d)+(b/e)+(c/f))/3
you simply cannot compute an "average percentage" by calculating the average of partial percentages.
suppose you have two samples:
1 out of 2   (50%)
100 out of 100 (100%)
would you say total percentage is 75%, just because 75 is average value between 50 and 100?
no, the correct formula would be  (1+100) / (2+100) = ~99%
hope this is clear now
cheers - Lorenzo -
0
 

Author Comment

by:Mehram
Comment Utility
Hi experts

Now I got it.

Thanks
0
 

Author Closing Comment

by:Mehram
Comment Utility
(A+B)/(C+D)=A/C+B/D
THE EQUATION CANNOT B TRUE IS EASY TO UNDERSTAND AND REMEMBER.
THANX FOR YOUR HELP
REGARDS:
(MAT)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now