jglapski
asked on
What's an easy way to add cumulatively in Foxpro?
I have a cursor whose data is in the following format:
Date Class Value
1/1/2000 RED 1.5
1/2/2000 RED 1.3
1/3/2000 RED 1.1
1/4/2000 RED 1.7
1/1/2000 BLUE 0.65
1/2/2000 BLUE 0.75
1/3/2000 BLUE 0.85
1/4/2000 BLUE 0.90
1/1/2000 GREEN 21.5
1/2/2000 GREEN 22.5
1/3/2000 GREEN 24.5
1/4/2000 GREEN 23.5
I am trying to add a cumulative value column, which is a sum of the value column, but added from most recent day to past, but done by class, as the following example indicates:
Date Class Value Cum_Value
1/1/2000 RED 1.5 5.6
1/2/2000 RED 1.3 4.1
1/3/2000 RED 1.1 2.8
1/4/2000 RED 1.7 1.7
1/1/2000 BLUE 0.65 3.15
1/2/2000 BLUE 0.75 2.50
1/3/2000 BLUE 0.85 1.75
1/4/2000 BLUE 0.90 0.90
1/1/2000 GREEN 21.5 92.0
1/2/2000 GREEN 22.5 70.5
1/3/2000 GREEN 24.5 48.0
1/4/2000 GREEN 23.5 23.5
What's the easiest and quickest (computationally) way of doing this?
Date Class Value
1/1/2000 RED 1.5
1/2/2000 RED 1.3
1/3/2000 RED 1.1
1/4/2000 RED 1.7
1/1/2000 BLUE 0.65
1/2/2000 BLUE 0.75
1/3/2000 BLUE 0.85
1/4/2000 BLUE 0.90
1/1/2000 GREEN 21.5
1/2/2000 GREEN 22.5
1/3/2000 GREEN 24.5
1/4/2000 GREEN 23.5
I am trying to add a cumulative value column, which is a sum of the value column, but added from most recent day to past, but done by class, as the following example indicates:
Date Class Value Cum_Value
1/1/2000 RED 1.5 5.6
1/2/2000 RED 1.3 4.1
1/3/2000 RED 1.1 2.8
1/4/2000 RED 1.7 1.7
1/1/2000 BLUE 0.65 3.15
1/2/2000 BLUE 0.75 2.50
1/3/2000 BLUE 0.85 1.75
1/4/2000 BLUE 0.90 0.90
1/1/2000 GREEN 21.5 92.0
1/2/2000 GREEN 22.5 70.5
1/3/2000 GREEN 24.5 48.0
1/4/2000 GREEN 23.5 23.5
What's the easiest and quickest (computationally) way of doing this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT *, 000000.000 As Cum_Value
FROM YourCursor
INTO CURSOR YourRWCursor READWRITE
and work with this new cursor.