Created
December 7, 2015 14:18
-
-
Save hkouns/2f672cedfc3da0676db8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE | |
@startdt DATETIME = '1/1/15' | |
, @enddt DATETIME = '12/1/15' | |
, @campusid INT = 0 | |
, @pledges INT = 0 | |
, @nontaxded INT = 0 | |
, @includeUnclosed INT = 1 | |
;WITH givers AS ( | |
SELECT | |
FamilyId | |
, CreditGiverId | |
, SpouseId | |
, SUM(Amount) AS Total | |
FROM Contributions2(@startdt, @enddt, @campusid, @pledges, @nontaxded, @includeUnclosed) | |
GROUP BY FamilyId, CreditGiverId, SpouseId | |
) | |
SELECT | |
p.Name2 | |
,p.PeopleId | |
,sp.FirstName Spouse | |
,sp.PeopleId SpouseID | |
,givers.Total | |
,givers.FamilyId | |
,p.ContributionOptionsId | |
,p.PositionInFamilyId | |
FROM givers | |
JOIN dbo.People p ON p.PeopleId = givers.CreditGiverId | |
LEFT JOIN dbo.People sp ON sp.PeopleId = givers.SpouseId | |
WHERE givers.Total > 50 | |
ORDER BY p.Name2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment