?
Solved

Percentage Calculation

Posted on 2010-11-08
5
Medium Priority
?
391 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:raulggonzalez
ID: 34083618
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 1000 total points
ID: 34083687
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 1000 total points
ID: 34083712
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
ID: 34083787
Hi experts

Now I got it.

Thanks
0
 

Author Closing Comment

by:Mehram
ID: 34085177
(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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

770 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