|
select StockNumber,InventoryName,Year1,Month1,RECEIVE_FROM_PO,RECEIVE_XFER,RECEIVE_ADJ,
_RETURN,ADJUSTMENT,ISSUE,PT_ISSUE,TRANSFER, SUM(ABS(RECEIVE_FROM_PO + RECEIVE_XFER + RECEIVE_ADJ + _RETURN))
- SUM(ABS(ADJUSTMENT + ISSUE + PT_ISSUE + TRANSFER))
as BALANCE, BALANCE as OPENING_BAL
into final2
from dbo.drug_summary$
GROUP BY StockNumber,InventoryName,Year1,Month1,RECEIVE_FROM_PO,RECEIVE_XFER,RECEIVE_ADJ,
_RETURN,ADJUSTMENT,ISSUE,PT_ISSUE,TRANSFER,BALANCE
|
|
|
|
|
Looks correct (enough) to me
What's wrong with it? Missing table?
|
|
|
|
|
Opening balance of current year is the closing balance of the previous year, and closing balance of the current year would be opening balance of the next year.
If this is clear for you then you can calculate from your data. Let me know if you still having some issue.
Thanks
-Amit Gajjar (MinterProject)
|
|
|
|