         Ranking Data with Running Sums
         ==============================
1.0 Problems
=== ========
Having spent a couple of days trying to find ways of
ranking sorted data in a table with a running sum
I tried all the ways in the MS Knowledge Base. 
Unfortunately none of them seemed to work very well. 

2.0 Ranking
=== =======
Method 1
========
One method involved using a global dynamic counter in
a query which was incremented every time an expression
was evaluated. However the resulting output was not
stable because every time the output was scrolled the
expression and hence the counter was re-evaluated and
the results became meaningless. 

Try running qRankData2 to see what I mean. This method
is described in MSKB article Q94397.

Method 2
========
Another method involved embedding SQL code in an
expression to create a kind of running sum using
Count(*).

To try this run qRankData3 in the examples. Note that
qSD3 is the alias name for the query qSortData3.

This worked fine for a small number of records. But when
I tried it with 1,000 records it took over an hour!!
This method is described in MSKB article Q120608.

3.0 Running Sums
=== ============
And nowhere could I find out how to create running sums
in tables. 

4.0 Solutions
=== =========
And so I wrote the macro and modules included with this
example.

The macro Rank_with_RunningSum is the code which does the
work for the user.

The ranking and creation of the running sum is done
with the modules rsRank and rsRunSum. The arguments for
these are the tablename for the output, the name of the
field for the rank or running sum, and the name of the
field holding the data to be processed.

It works for almost any number of records. The timing for
a thousand records was 20 seconds, slightly less than
the hour which Method 2 above took!!

And since the results are output to a table they remain
unchanged if the output is scrolled unlike Method 1 above.

I have included a Counter field in the examples to show
how useless it is for this purpose.

I offer this code as is in return for help received
when I've had problems. If you find this useful or if
you have any suggestions for improvement please do
contact me at 100340.673@compuserve.com. Good luck,

Chris Brady, 1/11/95.