我正在尝试选择上个月的期末余额并将其用作下个月的期初余额,但我似乎没有得到正确的结果。
我已使用此代码选择其他列并获得余额:
SELECT Year1,StockNumber,InventoryName,Month1,
SUM(ABS(RECEIVE_FROM_PO)) AS RPO,SUM(ABS(RECEIVE_XFER))AS XEFR,
SUM(ABS(RECEIVE_ADJ)) as RDJ,SUM(ABS(RETURN1)) AS RET,
SUM(ABS(TRANSFER)) as TSFR,SUM(ABS(ISSUE)) as ISS, SUM(ABS(PT_ISSUE))as PISS,
SUM(ABS(ADJUSTMENT)) as ADJ,
(Sum(ABS(RECEIVE_FROM_PO + RECEIVE_XFER + RECEIVE_ADJ + RETURN1)) - Sum(ABS(TRANSFER+ISSUE+PT_ISSUE+ADJUSTMENT))) as Balance
FROM dbo.Sheet2$
where Year1 ='' and InventoryName ='' and StockNumber =''
GROUP BY Year1,InventoryName,StockNumber,Month1,balance
使用此代码,我可以获得余额,现在我想将该余额用作下个月的期初余额。SQL 脚本是如何实现的,是否可以使用 Crystal Reports 完成?