SELECT 
AV.[VENDORNAME_FORDISPLAY] "Vendor name",
AV.[USERDEFINEDID] "Vendor ID",
AC.[DESCRIPTION] "Account description",
AC.[ACCOUNTNUMBER] "Account number",
VD.[TRANSACTIONTYPE], -- 1 = debit, 2 = credit
VD.[MISCENTRY], -- 0 = False, -1 = True
VD.[ROWNUMBER], -- rownumber on grid
VD.[AMOUNT] "Percent",
TE.[DESCRIPTION] "Class"

FROM 
DBO.AP7VENDORS AS AV
LEFT OUTER JOIN DBO.BBDISTRIBUTIONS AS VD ON AV.AP7VENDORSID = VD.PARENTID 
LEFT OUTER JOIN DBO.GL7ACCOUNTS AS AC ON VD.GL7ACCOUNTSID = AC.GL7ACCOUNTSID
LEFT OUTER JOIN DBO.TABLEENTRIES AS TE ON AC.CLASS = TE.TABLEENTRIESID

WHERE 
AV.[USERDEFINEDID]  =  '1002' --Alpha Graphics vendor ID in Sample data
and VD.PARENTOBJECTTYPE = 286 -- AP Vendor Parent Object only
and VD.MISCENTRY = 0 -- distribution only

Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Structured Query Language and the tools used to create and modify SQL statements and Crystal Reports. Our Customer Support may help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality.