select R.FIRST_NAME, R.MIDDLE_NAME, R.LAST_NAME, A.ADDRESS_BLOCK, P.NUM, MT.LIFETIMEMEMBERSHIP, MT.EXPIRESON, CATT.TEXT, AT.DESCRIPTION

from RECORDS R

--Address and phone number tables
join CONSTIT_ADDRESS CA on CA.CONSTIT_ID = R.ID
join ADDRESS A on A.ID = CA.ADDRESS_ID
join CONSTIT_ADDRESS_PHONES CAP on CAP.CONSTITADDRESSID = CA.ID
join PHONES P on P.PHONESID = CAP.PHONESID

--Membership tables
join MEMBER M on M.CONSTITID = R.ID
join MEMBERSHIPTRANSACTION MT on MT.MEMBERSHIPID = M.ID

--Constituent attribute tables
join CONSTITUENTATTRIBUTES CATT on CATT.PARENTID = R.ID
join ATTRIBUTETYPES AT on AT.ATTRIBUTETYPESID = CATT.ATTRIBUTETYPESID

--Returning only preferred addresses
--and attributes of "AGENCY - Number"
where
CA.PREFERRED = -1 and AT.DESCRIPTION = 'AGENCY - Number' 

Disclaimer: Blackbaud provides 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. Blackbaud 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.