Solved

Percentage Calculation

Posted on 2010-11-08
5
383 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
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 250 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 250 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS SQL with ODBC 5 36
sql server computed columns 11 31
sql query to calculate avaerage 21 40
MSSQL Import .SQL files - Increase Import Speed 9 42
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

809 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