select cdr.primaryContactId, cdr.focusAccount, cdr.cdr_recordId,cdr_dstCode, cdr_dstName, cdr_dstaddress1, cdr_dstaddress2, cdr_dstcity, cdr_dststate, cdr_dstzip, cdr.primaryContactId, cdr.createDate, case when cdr.primaryContactId = m.fspro_userid then 'Y' else 'N' end primaryContact, m.fspro_userid, m.orgId, m.orgType, m.firstName, m.lastName, m.phone, m.fax, m.cellPhone ,m.email, ter.name territoryName, cdr.setMethod, m.cajobfunction, i.contact_job_function, i.territory_name_id from tbl_CDR_Distributors cdr inner join tbl_LST_PartnerListItems pli on pli.partnerId = cdr.cdr_recordId and pli.listId = inner join tbl_IMPORT_ClientPartners i on i.fse_partnerId = cdr.cdr_recordId left outer join tbl_FSPro_Members m on m.fspro_userId = i.fse_contactId left outer join tbl_TER_Territories ter on ter.territoryId = cdr.cdr_territoryId order by territoryName, cdr_dstName, cdr.cdr_recordId
*** Preview *** #_recordSource# - #lsDateFormat( now() )# at #lstimeformat( Now() )# *** Preview ***
Focus Distributor Address Contact Territory
#focusAccount# #cdr_dstcode#
#cdr_dstName#
#cdr_dstaddress1#
#cdr_dstaddress2#
#cdr_dstcity#, #cdr_dststate# #cdr_dstzip#

#firstName# #lastName# #caJobFunction# - #contact_job_function#
&##160;&##160;email:#email#
&##160;&##160;phone:#phone#
&##160;&##160;cell:#cellPhone#
&##160;&##160;fax:#fax#
#contactHTML#None
#territoryName##setMethod#: Unassigned
#territory_name_id#
#application.datasource#: #qmd_check.recordCount#(#importCount#) Records Imported