解决方案: |
SELECT cWhCode,cWhName, TblQuanByRdCode_LWB2_0_Temp.cInvCode , Inventory.cInvName , ...
(SUM(ISNULL(iQCJCSL,0)) + SUM(CASE WHEN bRdFlag <>0 THEN isnull(iQuantity,0) ELSE 0 END) - SUM(CASE WHEN bRdFlag = 0 THEN isnull(iQuantity,0) ELSE 0 END))
* IsNull(Inventory.iInvSPrice,0) AS iQMJCJE ,
...
INTO TblResult_LWB2_0_Temp
FROM TblQuanByRdCode_LWB2_0_Temp INNER JOIN Inventory ON TblQuanByRdCode_LWB2_0_Temp.cInvCode = Inventory.cInvCode LEFT JOIN ComputationUnit ON Inventory.cComUnitCode = ComputationUnit.cComUnitCode
WHERE 1=1
Group By ...
|