:用友U810中現(xiàn)存量查詢的SQL
:/*在常規(guī)情況下,現(xiàn)存量不能按照部門查詢,如想對多個倉庫同時查詢有點麻煩,這條SQL可以解決*/
SELECT dbo.Warehouse.cWhCode AS 倉庫編碼,dbo.Warehouse.cWhName AS 倉庫名稱, dbo.Warehouse.cDepCode AS 部門編碼,Dep.cDepName AS 部門名稱,
dbo.CurrentStock.cInvCode AS 存貨編碼,
dbo.Inventory.cInvAddCode AS 存貨代碼,dbo.InventoryClass.cinvcname AS 存貨分類,dbo.Inventory.cInvStd AS 規(guī)格型號,
dbo.Inventory.cInvName AS 存貨名稱,Unit.cComUnitName AS 計量單位,
dbo.Inventory.cInvDefine6 AS 自定義項6,dbo.Inventory.iInvSPrice AS 參考成本,
SUM(ISNULL(dbo.CurrentStock.iQuantity, 0)) AS 現(xiàn)存量,
dbo.Inventory.iInvSPrice*SUM(ISNULL(dbo.CurrentStock.iQuantity, 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
INNER JOIN InventoryClass ON left(Inventory.cInvCCode,6) = InventoryClass.cInvCCode
INNER JOIN dbo.Department Dep ON dbo.Warehouse.cDepCode = Dep.cDepCode
GROUP BY dbo.Warehouse.cWhCode,dbo.Warehouse.cWhName, dbo.Warehouse.cDepCode, Dep.cDepName,
dbo.CurrentStock.cInvCode,
dbo.Inventory.cInvAddCode,dbo.InventoryClass.cinvcname,
dbo.Inventory.cInvName,Unit.cComUnitName,
dbo.Inventory.cInvDefine6,dbo.Inventory.iInvSPrice,
dbo.Inventory.cInvStd,dbo.CurrentStock.cBatch, dbo.CurrentStock.cFree1
having SUM(ISNULL(dbo.CurrentStock.iQuantity, 0)) >0
/*
上海企通數(shù)字科技有限公司,用心打造企業(yè)數(shù)字化!連續(xù)13年蟬聯(lián)用友全國TOP10服務(wù)商,專業(yè)銷售服務(wù)暢捷通、用友u8、用友NC等軟件,歡迎咨詢,咨詢熱線:400-820-8720,網(wǎng)址:http://maverickmindfulness.com/