*-- Suppose the numeric column Cum_Value already exists in YourTable
USE YourTable EXCLUSIVE
INDEX ON Class + DTOC(Date, 1) TAG CompOrder DESCENDING
LOCAL lnCumulSum, lcClass
lcClass = ''
lnCumulSum = 0
SCAN ALL
IF Class == lcClass
lnCumulSum = lnCumulSum + Value
ELSE
lnCumulSum = Value
lcClass = Class
ENDIF
REPLACE Cum_Value WITH lnCumulSum
ENDSCAN
DELETE TAG CompOrder
GO TOP
|