每个值的总和列更改foxpro中另一个字段的值。我怎样才能得到添加剂柱?我能够进行总计,但是对于所有项目,我怎样才能在每次项目更改时开始?
E.g。
Item Number QTY ADDITIVE
1045 50 50
1045 25 75
1045 35 110
2045 50 50
2045 50 100
2045 25 125
3056 30 30
3056 30 60
3056 30 90
答案 0 :(得分:0)
它看起来像简单的添加剂,但您如何计划存储并向最终用户呈现结果...在网格中或每个单独项目的最终运行总计?看起来这可能代表销售订单商品/销售数量。我可能会查询按项目排序的读/写游标,然后应用扫描循环来更新每个...类似于。
select ItemNumber, Qty, 000000 as RunningTotal ;
from YourTable ;
order by ItemNumber ;
into cursor C_Sample readwrite
lastItem = ""
runTotal = 0
scan
*/ If different item, reset running total back to zero
if lastItem != ItemNumber
runTotal = 0
endif
*/ Update running total
runTotal = runTotal + Qty
*/ Update the record column
replace RunningTotal with runTotal
*/ preserve the ID we just processed for comparison to next record
lastItem = ItemNumber
endscan
*/ Done...