DROP VIEW dbo.VW_AJUSTEAUTOMATICO
GO
CREATE VIEW dbo.VW_AJUSTEAUTOMATICO
AS
SELECT IN_INVENTPHISICAL.SITEID, 
    IN_INVENTPHISICAL.INVTIDSKU, 
    IN_INVENTPHISICAL.STOCKPHISICAL, 
    IN_INVENTORYDAT.QTYAVAIL,
    IN_INVENTORYDAT.AVGCOSTPEN,
    IN_INVENTORYDAT.AVGCOSTUSD,
    IN_SUBCATEGORY.CLASSUBID, 
    IN_SUBCATEGORY.CLASSID
FROM IN_INVENTPHISICAL INNER JOIN
    IN_INVENTORYDAT ON 
    IN_INVENTPHISICAL.INVTIDSKU = IN_INVENTORYDAT.INVTIDSKU
     AND 
    IN_INVENTPHISICAL.SITEID = IN_INVENTORYDAT.SITEID AND 
    IN_INVENTPHISICAL.STOCKPHISICAL <> IN_INVENTORYDAT.QTYAVAIL
     INNER JOIN
    IN_SUBCATEGORY ON 
    IN_INVENTPHISICAL.CLASSUBID = IN_SUBCATEGORY.CLASSUBID



