我需要在Oracle中进行增量求和。
我的情况如下:
RecordID Value
1 1
2 2
3 5
4 10我需要得到这样的东西:
RecordID Sum_incremental
1 (1)
2 (1 + 2)
3 (1 + 2 + 5)
4 (1 + 2 + 5 + 10)发布于 2011-03-17 18:46:42
线索: self join和group by。
解决方案:
select a.recordid, sum(b.value) sum_incremental from mytable a, mytable b
where b.recordid <= a.recordid group by a.recordidhttps://stackoverflow.com/questions/5337810
复制相似问题