SELECT dbo.Warehouse.cWhName AS 仓库名称,dbo.CurrentStock.cInvCode AS 存货编码,
dbo.Inventory.cInvName AS 存货名称, dbo.Inventory.cInvStd AS 规格型号,
dbo.Inventory.cInvAddCode AS 存货代码, dbo.CurrentStock.cBatch AS 批号,
dbo.CurrentStock.cFree1 AS 存货备注, SUM(ISNULL(dbo.CurrentStock.iQuantity, 0))
AS 现存量, SUM(ISNULL(dbo.CurrentStock.fAvaQuantity, 0)) AS 可用数量,
SUM(ISNULL(dbo.CurrentStock.fOutQuantity, 0)) AS 待发货数量,
SUM(ISNULL(dbo.CurrentStock.fInQuantity, 0)) AS 待入库数量,
SUM(ISNULL(dbo.CurrentStock.fTransInQuantity, 0)) AS 调拨在途数量,
SUM(ISNULL(dbo.CurrentStock.fTransOutQuantity, 0)) AS 调拨待发数量
FROM dbo.CurrentStock INNER JOIN
dbo.Inventory ON dbo.CurrentStock.cInvCode = dbo.Inventory.cInvCode INNER JOIN
dbo.Warehouse ON
dbo.Warehouse.cWhCode = dbo.CurrentStock.cWhCode INNER JOIN
dbo.ComputationUnit Unit ON
dbo.Inventory.cComUnitCode = Unit.cComunitCode
GROUP BY dbo.Warehouse.cWhName, dbo.CurrentStock.cInvCode,
dbo.Inventory.cInvName, dbo.Inventory.cInvStd, dbo.Inventory.cInvAddCode,
dbo.CurrentStock.cBatch, dbo.CurrentStock.cFree1
having CurrentStock.cInvCode = '物料编码'
dbo.Inventory.cInvName AS 存货名称, dbo.Inventory.cInvStd AS 规格型号,
dbo.Inventory.cInvAddCode AS 存货代码, dbo.CurrentStock.cBatch AS 批号,
dbo.CurrentStock.cFree1 AS 存货备注, SUM(ISNULL(dbo.CurrentStock.iQuantity, 0))
AS 现存量, SUM(ISNULL(dbo.CurrentStock.fAvaQuantity, 0)) AS 可用数量,
SUM(ISNULL(dbo.CurrentStock.fOutQuantity, 0)) AS 待发货数量,
SUM(ISNULL(dbo.CurrentStock.fInQuantity, 0)) AS 待入库数量,
SUM(ISNULL(dbo.CurrentStock.fTransInQuantity, 0)) AS 调拨在途数量,
SUM(ISNULL(dbo.CurrentStock.fTransOutQuantity, 0)) AS 调拨待发数量
FROM dbo.CurrentStock INNER JOIN
dbo.Inventory ON dbo.CurrentStock.cInvCode = dbo.Inventory.cInvCode INNER JOIN
dbo.Warehouse ON
dbo.Warehouse.cWhCode = dbo.CurrentStock.cWhCode INNER JOIN
dbo.ComputationUnit Unit ON
dbo.Inventory.cComUnitCode = Unit.cComunitCode
GROUP BY dbo.Warehouse.cWhName, dbo.CurrentStock.cInvCode,
dbo.Inventory.cInvName, dbo.Inventory.cInvStd, dbo.Inventory.cInvAddCode,
dbo.CurrentStock.cBatch, dbo.CurrentStock.cFree1
having CurrentStock.cInvCode = '物料编码'