vw_Varyant_Barkod_Items
SELECT BARKOD.ITMUNITAREF, ORL.ORDFICHEREF FisRef, BARKOD.BARCODE Barkod, IT.NAME Malzeme_Aciklamasi, ORL.AMOUNT Siparis_Miktar, UNT.NAME Birimsetiadi, UNT.CODE Birimsetikodu, ISNULL(VARYANT.NAME,'')VaryantAdi FROM LG_003_02_ORFLINE ORL --------------------------------------------- INNER JOIN (SELECT LOGICALREF ,CODE,NAME FROM LG_003_ITEMS )IT ON IT.LOGICALREF=ORL.STOCKREF AND ORL.LINETYPE=0 -------------------------------------------- INNER JOIN (SELECT LOGICALREF ,NAME,CODE FROM LG_003_UNITSETL )UNT ON UNT.LOGICALREF=ORL.UOMREF -------------------------------------------- INNER JOIN (SELECT UNITLINEREF,ITEMREF,LOGICALREF,VARIANTREF FROM LG_003_ITMUNITA )ITM ON ITM.UNITLINEREF=UNT.LOGICALREF AND ITM.ITEMREF=IT.LOGICALREF -------------------------------------------- INNER JOIN (SELECT ITMUNITAREF,UNITLINEREF,TYP,BARCODE,VARIANTREF,ITEMREF FROM LG_003_UNITBARCODE )BARKOD ON (BARKOD.UNITLINEREF=UNT.LOGICALREF AND TYP=0 AND BARKOD.ITMUNITAREF=ITM.LOGICALREF AND BARKOD.VARIANTREF=ORL.VARIANTREF) --INNER JOIN (SELECT BARCODE,VARIANTREF -- FROM LG_003_UNITBARCODE )VARYANTBARKOD ON VARYANTBARKOD.VARIANTREF=ORL.VARIANTREF -------------------------------------------- LEFT JOIN ( SELECT CODE,NAME,ITEMREF,LOGICALREF FROM LG_003_VARIANT ) VARYANT ON VARYANT.LOGICALREF=ORL.VARIANTREF -------------------------------------------- WHERE ORL.CANCELLED=0 AND ORDFICHEREF>0 AND AMOUNT>0 AND AMOUNT>SHIPPEDAMOUNT -- and ORL.STOCKREF=31964 --AND IT.LOGICALREF=10621 --AND ORL.ORDFICHEREF=10981