0

我有一张如下表-

MID Period  Total Amount    New Total Amount 
123 01  45566          Total Amount ie 45566
123 02  -5677          Total Amount – (Total Amount for month of 01) 
123 03  7899           Total Amount – (Total Amount for month of 01 
                               + TotalAmount for month of 02 )  
235 01  5677           Total Amount  i.e. 5677
235 02  768878         Total Amount –
                               (Total Amount for month of 01) ie 768878–(5677)
235 03  -676787 

如何编写查询以获取列新总金额。

谢谢!

4

1 回答 1

0
total_amount - nvl(sum(total_amount) over 
    (partition by mid order by period 
     rows between unbounded preceding and 1 preceding), 0)
于 2013-06-20T18:15:47.840 回答