0

我正在尝试选择上个月的期末余额并将其用作下个月的期初余额,但我似乎没有得到正确的结果。

我已使用此代码选择其他列并获得余额:

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 完成?

4

1 回答 1

0

水晶报表有做sum、min、max等分组功能的能力。它具有所有丰富的功能。如果创建查询失败,在水晶报表中取表Sheet2$,然后创建汇总字段对于查询中的每个总和。

于 2012-11-29T11:31:21.967 回答