SELECT top 3 api.COMPANY
,ISNULL(apd.DIS_ACCOUNT,'')
,ISNULL(apd.DIS_ACCT_UNIT,'')
,ISNULL(apd.DIS_SUB_ACCT,'')
,ISNULL(apv.VENDOR_VNAME,'') -----AS VENDORNAME
,api.INVOICE_DTE -----AS INV_DATE
,api.INVOICE
,api.TRAN_INV_AMT ----AS AMOUNT
,api.DESCRIPTION
,api.BATCH_NUM ----AS Batch
,api.VENDOR
,api.L_INDEX
,ISNULL(lhap.NAME,'') ----AS FIRSTCOMMENT
,ISNULL(lhap.[OBJECT],'') ----AS SecondComment
,''
FROM APINVOICE AS api
INNER JOIN APVENMAST AS apv ON
api.COMPANY = apv.VENDOR_GROUP AND api.VENDOR = apv.VENDOR
LEFT OUTER JOIN APDISTRIB AS apd ON api.OBJ_ID = apd.API_OBJ_ID
LEFT outer JOIN L_HAPI AS lhap ON api.L_INDEX = lhap.L_INDEX
--WHERE api.INVOICE=''
ORDER BY apd.DIS_ACCOUNT,api.VENDOR, api.INVOICE_DTE