zhangjinrui(提问者)select * ,sum(tb.数量)over(partition by tb.存货编码 order by RN)as 累积出库数量
from (select Row_Number() over (partition by \'\' order by r3.ccode) as RN,r3.ccode as 销售出库单号 ,rs3.cInvCode as 存货编码,rs3.iQuantity as 数量,rs3.iorderseq as 行号,rs3.cbdlcode as 业务单号,rs3.iordercode as 销售订单号
from rdrecord32 r3
left join rdrecords32 rs3
on r3.id=rs3.ID
where r3.cCode=\'2103003833\'
)tb--数量正确