我需要能够从供应中减去每天的需求,根据每天的需求给出一个数字,见图像
我需要能够说出06/03/14的库存水平是7169(库存) - 减去该日期的需求3157 = 4012
在2014年3月18日,我需要能够增加来自06/03/14的需求& 2014年3月18日并从库存号码(7169) - (3157 + 2632)= 1380中扣除,以便每个日期我将重新获得的数字加上之前的数字并从库存中减去
最好在报表生成器或sql中执行此操作,下面是我的脚本(需要ALLCOMPREQD并且BINST是我的库存级别,WORDSTAT是我的日期
SELECT dbo.mbf010.wordno,
dbo.mbf010.partno_wor,
dbo.mbb010.description AS [WO Description],
dbo.mbf020.partno_f02com,
MBB010_1.description AS [Part Description],
dbo.mbf020.allcompreqd,
dbo.mbf010.wordstart,
dbo.mbc010.binst
FROM dbo.mbf010
INNER JOIN dbo.mbf020
ON dbo.mbf010.account15_wor = dbo.mbf020.account15_f02par
AND dbo.mbf010.wordno = dbo.mbf020.wordno_f02par
AND dbo.mbf010.wordnosuf = dbo.mbf020.wordnosuf_f02par
AND dbo.mbf010.procstage_wor = dbo.mbf020.procstage_f02par
INNER JOIN dbo.mbb010
ON dbo.mbf010.partno_wor = dbo.mbb010.partno
AND dbo.mbf010.account15_wor = dbo.mbb010.account15
INNER JOIN dbo.mbb010 AS MBB010_1
ON dbo.mbf020.account15_f02par = MBB010_1.account15
AND dbo.mbf020.partno_f02com = MBB010_1.partno
INNER JOIN dbo.mbc010
ON dbo.mbf020.account15_f02par = dbo.mbc010.account15_inv
AND dbo.mbf020.partno_f02com = dbo.mbc010.partno_inv
WHERE ( dbo.mbf020.partno_f02com = '04LEF009' )
AND ( dbo.mbf020.allcompreqd > 0 )