spFundraiserMultipleDonationTotals

Parameters

Parameter Parameter Type Mode Description
@FrIDs nvarchar(4000) IN

Definition

Copy


CREATE procedure [dbo].[spFundraiserMultipleDonationTotals]
            (
                @FrIDs nvarchar(4000)
            )
            AS

            BEGIN
                set nocount on
                declare @IDTable table
                (
                    ID INT
                )
                Insert into @IDTable select ID from dbo.fnMakeIDsTableFromString(@FrIDs, ',')

                declare @offAmt money
                declare @offCount int
                declare @onAmt money
                declare @onCount int

                SELECT    @offAmt = isnull(sum(FRDonation.Amount),0), @offCount = count(FRDonation.ID)
                FROM dbo.DonationTransactions Donation
                inner join dbo.FundRaiserDonations FRDonation on FRDonation.DonationTransactionsID = Donation.DonationTransactionsID
                inner join dbo.FundRaiserSolicitors Solicitor on Solicitor.ID = FRDonation.SolicitorID
                inner join @IDTable it on it.id=Solicitor.RootFundraiserID
                WHERE
                FRDonation.IsOffline = 1 and  FRDonation.IsAthon = 0 and Donation.IsDeleted = 0 and Donation.Status = 1

                select @onAmt=isnull(sum(FRDonation.Amount),0), @onCount=count(FRDonation.ID)
                FROM dbo.DonationTransactions Donation
                inner join dbo.FundRaiserDonations FRDonation on FRDonation.DonationTransactionsID = Donation.DonationTransactionsID
                inner join dbo.FundRaiserSolicitors Solicitor on Solicitor.ID = FRDonation.SolicitorID
                inner join @IDTable it on it.id=Solicitor.RootFundraiserID
                WHERE FRDonation.IsOffline = 0 and FRDonation.IsAthon = 0 and Donation.IsDeleted = 0 and Donation.Status = 1

                select @offAmt [OfflineAmount], @offCount [OfflineCount], @onAmt [OnlineAmount], @onCount [OnlineCount]
            END