--CREATE VIEW
SELECT 7 AS i ,
CAST(inventory.cInvCCode AS NVARCHAR(12)) AS Grade ,
IA_Subsidiary.cInvCode ,
cInvAddCode ,
cInvName ,
cInvStd ,
ComputationUnit.cComUnitName ,
iInvWeight ,
CAST(SUM(ISNULL(CAST(iAInQuantity AS DECIMAL(38, 2)), 0)
- ISNULL(CAST(iAOutQuantity AS DECIMAL(38, 2)), 0)) AS FLOAT) AS QcQuantity ,
CAST(SUM(ISNULL(CAST(CAST(iAInPrice AS DECIMAL(38, 10)) AS DECIMAL(38,
2)), 0)
- ISNULL(CAST(CAST(iAOutPrice AS DECIMAL(38, 10)) AS DECIMAL(38,
2)), 0)) AS DECIMAL(38,
2)) AS QcPrice,
CAST(SUM(ISNULL(CAST(iDebitDifCost AS DECIMAL(38, 2)), 0)
- ISNULL(CAST(iCreditDifCost AS DECIMAL(38, 2)), 0)) AS DECIMAL(38,
2)) AS qcDif,
CAST(0 AS FLOAT) AS InQuantity,
CAST(0 AS DECIMAL(38, 2)) AS InPrice,
CAST(0 AS DECIMAL(38, 2)) AS InDif,
CAST(0 AS FLOAT) AS OutQuantity,
CAST(0 AS DECIMAL(38, 2)) AS