这样?
select
材料品号,
排产日期,
期初数+sum(可用量) over(partition by 材料品号 order by 材料品号,排产日期) as 实际可用量
from emp
你这个写错了?应该每一行差都是用量,
为什么第一行和第二行的差是前面两行的和?