开窗函数应用
取相对于本行上一行的值
代码块
with abc as
(select '10000547'o_code,'2011-10-01'basdate,1 nums from dual union all
select '10000547'o_code,'2012-10-01'basdate,2 nums from dual union all
select '10000547'o_code,'2013-10-01'basdate,3 nums from dual )
select o_code,basdate,nums,lag(nums,1)over(order by basdate) from abc
执行结果: