Note: This code is written and intended for use in Microsoft Access and will not work in the SQL Server Query Analyzer.




SELECT

IIf([DBO_Records].[Key_Indicator]='I',[DBO_Records].[First_Name] & ' ' & IIf(Len(RTrim([DBO_Records].[Middle_Name]))>0,Left([DBO_Records].[Middle_Name],1) & '. ','') & [DBO_Records].[Last_Name],[DBO_Records].[Org_Name]) AS Constituent, DBO_InstallmentPayment.PledgeId, Format(DBO_GiftSplit.Amount,"Currency") AS [Pledge Amount], DBO_FUND.DESCRIPTION AS Fund, Format(Sum([DBO_InstallmentPayment].[Amount]),"Currency") AS [Write Off Amount]



FROM

(((((DBO_RECORDS INNER JOIN DBO_CONSTIT_GIFTS ON DBO_RECORDS.ID = DBO_CONSTIT_GIFTS.CONSTIT_ID) INNER JOIN DBO_GIFT ON DBO_CONSTIT_GIFTS.GIFT_ID = DBO_GIFT.ID) INNER JOIN DBO_InstallmentPayment ON DBO_GIFT.ID = DBO_InstallmentPayment.PaymentId) INNER JOIN DBO_GIFT AS DBO_GIFT_1 ON DBO_InstallmentPayment.PledgeId = DBO_GIFT_1.ID) INNER JOIN DBO_GiftSplit ON DBO_GIFT_1.ID = DBO_GiftSplit.GiftId) INNER JOIN DBO_FUND ON DBO_GiftSplit.FundId = DBO_FUND.ID



WHERE

(((DBO_GIFT.TYPE)=21 Or (DBO_GIFT.TYPE)=22))



GROUP BY

IIf([DBO_Records].[Key_Indicator]='I',[DBO_Records].[First_Name] & ' ' & IIf(Len(RTrim([DBO_Records].[Middle_Name]))>0,Left([DBO_Records].[Middle_Name],1) & '. ','') & [DBO_Records].[Last_Name],[DBO_Records].[Org_Name]), DBO_InstallmentPayment.PledgeId, DBO_FUND.DESCRIPTION, IIf(DBO_Records.Key_Indicator='I',DBO_Records.Last_Name & ", " & DBO_Records.First_Name & ", " & DBO_Records.Middle_Name & ", " & DBO_Records.ID,DBO_Records.Org_Name), DBO_GiftSplit.Amount



ORDER BY

IIf(DBO_Records.Key_Indicator='I',DBO_Records.Last_Name & ", " & DBO_Records.First_Name & ", " & DBO_Records.Middle_Name & ", " & DBO_Records.ID,DBO_Records.Org_Name);

 

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.