SELECT LG_xxx_ITEMS.STGRPCODE AS 'Hiyerarşi', LG_xxx_xx_ORFICHE.DATE_ AS 'Sip.Tarihi', LG_xxx_xx_ORFICHE.FICHENO AS 'Sip.Fiş No', LG_xxx_xx_INVOICE.DATE_ AS 'Fat.Tarihi', LG_xxx_xx_INVOICE.FICHENO AS 'Fat.Fiş No:', LG_xxx_CLCARD.CODE AS 'UL', LG_xxx_CLCARD.DEFINITION_ AS 'ÜNVAN', LG_xxx_CLCARD.TRADINGGRP AS 'Prom.Snf.', LG_xxx_ITEMS.CODE AS 'KOD', LG_xxx_ITEMS.NAME AS 'MAMUL', LG_xxx_xx_ORFLINE.AMOUNT AS 'Sip.Mik.AD.', LG_xxx_xx_STLINE.AMOUNT AS 'Fat. Mik. AD.', LG_xxx_UNITSETL.CODE AS 'Birim', LG_xxx_xx_STLINE.LINENET AS 'NSV', LG_xxx_xx_STLINE.TOTAL AS 'GSV'
FROM UNITY.dbo.LG_xxx_xx_INVOICE LG_xxx_xx_INVOICE, UNITY.dbo.LG_xxx_xx_ORFICHE LG_xxx_xx_ORFICHE, UNITY.dbo.LG_xxx_xx_ORFLINE LG_xxx_xx_ORFLINE, UNITY.dbo.LG_xxx_xx_STLINE LG_xxx_xx_STLINE, UNITY.dbo.LG_xxx_CLCARD LG_xxx_CLCARD, UNITY.dbo.LG_xxx_ITEMS LG_xxx_ITEMS, UNITY.dbo.LG_xxx_UNITSETF LG_xxx_UNITSETF, UNITY.dbo.LG_xxx_UNITSETL LG_xxx_UNITSETL
WHERE LG_xxx_xx_STLINE.STOCKREF = LG_xxx_ITEMS.LOGICALREF AND LG_xxx_xx_STLINE.INVOICEREF = LG_xxx_xx_INVOICE.LOGICALREF AND LG_xxx_xx_STLINE.ORDFICHEREF = LG_xxx_xx_ORFICHE.LOGICALREF AND LG_xxx_xx_STLINE.ORDTRANSREF = LG_xxx_xx_ORFLINE.LOGICALREF AND LG_xxx_xx_STLINE.CLIENTREF = LG_xxx_CLCARD.LOGICALREF AND LG_xxx_UNITSETL.UNITSETREF = LG_xxx_UNITSETF.LOGICALREF AND LG_xxx_xx_ORFLINE.UOMREF = LG_xxx_UNITSETL.LOGICALREF AND LG_xxx_xx_ORFLINE.USREF = LG_xxx_UNITSETF.LOGICALREF AND ((LG_xxx_xx_STLINE.SOURCEINDEX=0 And LG_xxx_xx_STLINE.SOURCEINDEX=0) AND (LG_xxx_CLCARD.ACTIVE=0) AND (LG_xxx_ITEMS.ACTIVE=0) AND (LG_xxx_xx_STLINE.LINETYPE In (0,6,1)) AND (LG_xxx_xx_ORFICHE.TRCODE=1) AND (LG_xxx_xx_INVOICE.CANCELLED=0) AND (LG_xxx_xx_STLINE.CANCELLED=0) AND (LG_xxx_xx_INVOICE.GRPCODE=2) AND (LG_xxx_xx_INVOICE.TRCODE=8) AND (LG_xxx_xx_ORFICHE.DATE_ Between {ts '2012-01-01 00:00:00'} And {ts '2012-12-31 00:00:00'}))
ORDER BY LG_xxx_xx_INVOICE.DATE_, LG_xxx_xx_ORFICHE.FICHENO
Benim sipariş ve faturaları ortak kullandığım sorgum işinize yarar umarım.