Query percent totals...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to build a query that equates percentages directly next to the
result (line by line). The percentages would be based on the total sum of the
query results. Something like this...

Result %of Total Cumulative Total Cumlative %
23 % 23 %
45 % 68 %
98 % 166 %
43 % 209 %
And so on.....
Total = 209 for this example, but could be any number

Any help would be greatly appreciated...

Thanks
 
Here is a query the Calculates a cumulative total and Percentages based on a
table called tblRank that has just two columns "ID" and "Score".

SELECT RR.ID, RR.Score,
Format([Score]/[Cumulative],"0%") AS PctTotal,
(SELECT Sum(tblRank.Score)From tblRank Where tblRank.ID <= RR.ID) AS
Cumulative,
Format([Cumulative]/(SELECT Sum(tblRank.Score)From tblRank),"0%") AS
PctCumulative
FROM tblRank AS RR
ORDER BY RR.ID

Here are the results I got from the values in my table:
ID Score PctTotal Cumulative PctCumulative
1 100 100% 100 11%
2 99 50% 199 21%
3 97 33% 296 32%
4 100 25% 396 42%
5 100 20% 496 53%
6 99 17% 595 64%
7 98 14% 693 74%
8 88 11% 781 83%
9 58 7% 839 90%
10 97 10% 936 100%


If I understood you question correctly, than all you need to do is to plug
in your table name and column names and you are good to go.
 
Back
Top