Duplicate records when joining Member, Gift and MembershipTransaction tables
I am new to Raisers Edge and was trying to write a SQL query against the database to get the Gifts along with Gift Date and the corresponding MembershipTransaction. I am basically trying to do this in order to get the Memberships of a certain type directly from the database. I would really appreciate if someone can help me out with this.
Please see query below that I am using:
Now the problem is that I am seeing duplicate records for a particular Member. For e.g. if a Member X purchased and renewed Memberships on 4 different dates. I am seeing 16 records instead of just 4 records. For each Gift Date, there are 4 different transaction dates as a result of the INNER JOIN. Can someone please help me out with this? Again I am new to Raisers Edge and not sure what the right way to do this is.
Thank you,
MK
Comments
-
Hi Malavika,
Try restricting your SELECT columns and using DISTINCT.
Cheers,
Steve Cinquegrana | CEO and Principal Developer | Protégé Solutions
0 -
Steven Cinquegrana:
Hi Malavika,
Try restricting your SELECT columns and using DISTINCT.
Cheers,
Steve Cinquegrana | CEO and Principal Developer | Protégé Solutions
Hi Steve,
Thank you for the response. I did try doing that but it still gives me duplicate columns.
-MK
0 -
That doesn't sound right; if I use your query and SELECT DISTINCT m.ID, etc I only get unique Membership IDs.
If you expand the SELECT columns one-by-one, at some point you'll start to get duplicate rows and that will tell you which table join is causing the problems.
A quick-and-dirty approach is to use the result of the original query as a sub-query but I'd really recommend the first approach.
Cheers, Steve
0 -
Malavika Krishnaswamy:
Steven Cinquegrana:
Hi Malavika,
Try restricting your SELECT columns and using DISTINCT.
Cheers,
Steve Cinquegrana | CEO and Principal Developer | Protégé Solutions
Hi Steve,
Thank you for the response. I did try doing that but it still gives me duplicate columns.
-MKWhen using distinct are you getting the same number of dupes, or does the distinct reduce the number (per individual)? We are hosted, so I do not have backend access, but when querying using the RE Query, I do know the gifts can be counted multiple times if they are Split Gifts. Could that be your issue?
0 -
Larry Wheeler:
Malavika Krishnaswamy:
Steven Cinquegrana:
Hi Malavika,
Try restricting your SELECT columns and using DISTINCT.
Cheers,
Steve Cinquegrana | CEO and Principal Developer | Protégé Solutions
Hi Steve,
Thank you for the response. I did try doing that but it still gives me duplicate columns.
-MKWhen using distinct are you getting the same number of dupes, or does the distinct reduce the number (per individual)? We are hosted, so I do not have backend access, but when querying using the RE Query, I do know the gifts can be counted multiple times if they are Split Gifts. Could that be your issue?
The query I am using is as seen below:
select distinctm.ID as 'Membership ID',m.Date_Joined as key_date,mt.ActivityDate as transaction_date,g.DTE as gift_date,g.CONSTIT_ID,r.FIRST_NAME + ' ' + r.LAST_NAME as 'Primary Member Name',mc.MembershipCategoryID,mt.Dues as 'Dues\\Amount',m.Added_By,u.NAME--te.LONGDESCRIPTION as 'Gift Code'from MEMBER minner join RECORDS r on r.ID = m.ConstitIDinner join CONSTIT_GIFTS cg on cg.CONSTIT_ID = r.IDinner join GIFT g on g.ID = cg.GIFT_IDleft join TABLEENTRIES te on te.TABLEENTRIESID = g.GIFT_CODEinner join MembershipTransaction mt on mt.MembershipID = m.IDinner join MembershipCategory mc on mc.MembershipCategoryID = mt.Categoryinner join USERS u on u.USER_ID = m.ADDED_BYwhere te.LONGDESCRIPTION like '%DMP - Membership%'--and m.Added_By in ('24','49')order by m.ID,key_date, gift_date
I am trying to get the Memberships by Gift Date along with the Activity Date from the MembershipTransaction table but when I add the join to the MembershipTransaction table, that is where the duplicates start appearing. For e.g. If there are 4 different Gifts and 4 different transaction dates, I am getting a total of 16 rows for one Member ID.
Thank you,
MK
0 -
Malavika Krishnaswamy:
The query I am using is as seen below:
select distinctm.ID as 'Membership ID',m.Date_Joined as key_date,mt.ActivityDate as transaction_date,g.DTE as gift_date,g.CONSTIT_ID,r.FIRST_NAME + ' ' + r.LAST_NAME as 'Primary Member Name',mc.MembershipCategoryID,mt.Dues as 'Dues\\Amount',m.Added_By,u.NAME--te.LONGDESCRIPTION as 'Gift Code'from MEMBER minner join RECORDS r on r.ID = m.ConstitIDinner join CONSTIT_GIFTS cg on cg.CONSTIT_ID = r.IDinner join GIFT g on g.ID = cg.GIFT_IDleft join TABLEENTRIES te on te.TABLEENTRIESID = g.GIFT_CODEinner join MembershipTransaction mt on mt.MembershipID = m.IDinner join MembershipCategory mc on mc.MembershipCategoryID = mt.Categoryinner join USERS u on u.USER_ID = m.ADDED_BYwhere te.LONGDESCRIPTION like '%DMP - Membership%'--and m.Added_By in ('24','49')order by m.ID,key_date, gift_date
I am trying to get the Memberships by Gift Date along with the Activity Date from the MembershipTransaction table but when I add the join to the MembershipTransaction table, that is where the duplicates start appearing. For e.g. If there are 4 different Gifts and 4 different transaction dates, I am getting a total of 16 rows for one Member ID.
Thank you,
MKThe query issue ihere s the fact that you're linking to the gifts through constit_gifts and separately linking the membershiptransaction table, so it's going to pull ... I think it's called a cartesian product? of all the gift/transaction combinations.
What you need to do is link the gift to the transaction via the TransactionGift table, instead of using constit_gifts. (edited yet again to add: you might need to do a subquery here actually, if you have both pledges and payments linked to membership gifts, so you don't double count them.)
0 -
Hi James,
Thank you so much for the response. I believe the CONSTIT_GIFTS table was present because if I try joining RECORDS and GIFTS directly using the AccountID and Record.ID, I am not seeing any results at all (Not sure why this is the case). Please see below the revised query that I tried using which did not work. I am not sure what you mean by sub-query. Again I am new to this so thank you for all the inputs.
select distinct m.ID as 'Membership ID',m.Date_Joined as key_date,mt.ActivityDate as transaction_date,g.DTE as gift_date,g.CONSTIT_ID,r.FIRST_NAME + ' ' + r.LAST_NAME as 'Primary Member Name',mc.MembershipCategoryID,mt.Dues as 'Dues\\Amount',m.Added_By,u.NAME,te.LONGDESCRIPTION as 'Gift Code'from MEMBER minner join RECORDS r on r.ID = m.ConstitIDinner join GIFT g on g.AccountID = r.IDinner join TransactionGift tg on tg.GiftID = g.IDleft join TABLEENTRIES te on te.TABLEENTRIESID = g.GIFT_CODEinner join MembershipTransaction mt on mt.ID = tg.TransactionIDinner join MembershipCategory mc on mc.MembershipCategoryID = mt.Categoryinner join USERS u on u.USER_ID = m.ADDED_BYwherete.LONGDESCRIPTION like '%DMP - Membership%'andm.ID = 67978and m.Added_By in ('24','49')order by m.ID,key_date, gift_dateThanks again,
MK
James Andrews:Malavika Krishnaswamy:
The query I am using is as seen below:
select distinctm.ID as 'Membership ID',m.Date_Joined as key_date,mt.ActivityDate as transaction_date,g.DTE as gift_date,g.CONSTIT_ID,r.FIRST_NAME + ' ' + r.LAST_NAME as 'Primary Member Name',mc.MembershipCategoryID,mt.Dues as 'Dues\\Amount',m.Added_By,u.NAME--te.LONGDESCRIPTION as 'Gift Code'from MEMBER minner join RECORDS r on r.ID = m.ConstitIDinner join CONSTIT_GIFTS cg on cg.CONSTIT_ID = r.IDinner join GIFT g on g.ID = cg.GIFT_IDleft join TABLEENTRIES te on te.TABLEENTRIESID = g.GIFT_CODEinner join MembershipTransaction mt on mt.MembershipID = m.IDinner join MembershipCategory mc on mc.MembershipCategoryID = mt.Categoryinner join USERS u on u.USER_ID = m.ADDED_BYwhere te.LONGDESCRIPTION like '%DMP - Membership%'--and m.Added_By in ('24','49')order by m.ID,key_date, gift_date
I am trying to get the Memberships by Gift Date along with the Activity Date from the MembershipTransaction table but when I add the join to the MembershipTransaction table, that is where the duplicates start appearing. For e.g. If there are 4 different Gifts and 4 different transaction dates, I am getting a total of 16 rows for one Member ID.
Thank you,
MKThe query issue ihere s the fact that you're linking to the gifts through constit_gifts and separately linking the membershiptransaction table, so it's going to pull ... I think it's called a cartesian product? of all the gift/transaction combinations.
What you need to do is link the gift to the transaction via the TransactionGift table, instead of using constit_gifts. (edited yet again to add: you might need to do a subquery here actually, if you have both pledges and payments linked to membership gifts, so you don't double count them.)
0 -
Malavika Krishnaswamy:
Hi James,
Thank you so much for the response. I believe the CONSTIT_GIFTS table was present because if I try joining RECORDS and GIFTS directly using the AccountID and Record.ID, I am not seeing any results at all (Not sure why this is the case). Please see below the revised query that I tried using which did not work. I am not sure what you mean by sub-query. Again I am new to this so thank you for all the inputs.
select distinct m.ID as 'Membership ID',m.Date_Joined as key_date,mt.ActivityDate as transaction_date,g.DTE as gift_date,g.CONSTIT_ID,r.FIRST_NAME + ' ' + r.LAST_NAME as 'Primary Member Name',mc.MembershipCategoryID,mt.Dues as 'Dues\\Amount',m.Added_By,u.NAME,te.LONGDESCRIPTION as 'Gift Code'from MEMBER minner join RECORDS r on r.ID = m.ConstitIDinner join GIFT g on g.AccountID = r.IDinner join TransactionGift tg on tg.GiftID = g.IDleft join TABLEENTRIES te on te.TABLEENTRIESID = g.GIFT_CODEinner join MembershipTransaction mt on mt.ID = tg.TransactionIDinner join MembershipCategory mc on mc.MembershipCategoryID = mt.Categoryinner join USERS u on u.USER_ID = m.ADDED_BYwherete.LONGDESCRIPTION like '%DMP - Membership%'andm.ID = 67978and m.Added_By in ('24','49')order by m.ID,key_date, gift_dateThanks again,
MK
Right, but you don't have to link the constituent and the gift directly -- you end up linking the gift to the constituent indirectly via the memership transaction. I mean, haven't done a ton of membership querying but I think it's something more like:
Member m
left join records r on m.constit_id = r.id
left join membershiptransaction mt on m.id = mt.membershipid
left join transactiongift tg on mt.id = tg.transactionid
left join gift g on tg.giftid = g.id
etc.
0 -
A good way to get started on direct SQL queries of the RE back-end database is to have a look at the SQL generated by RE for a similar, perhaps simpler, query using View/SQL (Ctrl-Q):
(For this you need the optional-but-usually-free RODBA module.)
You can copy and paste this query into a new SQL Server Management Studio query pane (don't forget to "unpack" any sub-queries from the tabs starting with "DBO") and then run it, sometimes after a bit of fiddling. It will show you the table joins you'll need to replicate.
Cheers,
Steve Cinquegrana | CEO and Principal Developer | Protégé Solutions
0 -
Steven Cinquegrana:
You can copy and paste this query into a new SQL Server Management Studio query pane (don't forget to "unpack" any sub-queries from the tabs starting with "DBO")
You know, I've been Ctrl-Qing queries for years to yoink code from RE and I swear I never noticed that before. THANK YOU.0 -
Sad to learn that the RODBA module is only available if you are self hosted....0
-
Heather MacKenzie:
Sad to learn that the RODBA module is only available if you are self hosted....True. But apparently there are other hosting providers besides blackbaud, who will allow you back end DB access. So if you really need to be hosted but you also need that access, you could look into one of them.
0 -
James Andrews: True. But apparently there are other hosting providers besides blackbaud, who will allow you back end DB access. So if you really need to be hosted but you also need that access, you could look into one of them.
Agreed. You can also look at cloud providers such as Amazon AWS, which we use for our Blackbaud product demonstrations. We have a basic cloud server set up and can use it as if it were in the room next-door. It's a good middle option between self- and Blackbaud-hosted if you want 100% control of your access/data. I'm not sure if AWS does, but some cloud providers will also manage your backups.
Cheers,
Steve Cinquegrana | CEO and Principal Developer | Protégé Solutions
0 -
Can someone please let me know what is the estimated cost of RODBA module? I have tried looking for this information online but unable to find any details.0
-
Malavika Krishnaswamy:
Can someone please let me know what is the estimated cost of RODBA module? I have tried looking for this information online but unable to find any details.It is automatically included with certain levels of support/maintenance.
0
Categories
- All Categories
- Shannon parent
- shannon 2
- shannon 1
- 21 Advocacy DC Users Group
- 14 BBCRM PAG Discussions
- 89 High Education Program Advisory Group (HE PAG)
- 28 Luminate CRM DC Users Group
- 8 DC Luminate CRM Users Group
- Luminate PAG
- 5.9K Blackbaud Altru®
- 58 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 409 bbcon®
- 2.1K Blackbaud CRM™ and Blackbaud Internet Solutions™
- donorCentrics®
- 1.1K Blackbaud eTapestry®
- 2.8K Blackbaud Financial Edge NXT®
- 1.1K Blackbaud Grantmaking™
- 527 Education Management Solutions for Higher Education
- 1 JustGiving® from Blackbaud®
- 4.6K Education Management Solutions for K-12 Schools
- Blackbaud Luminate Online & Blackbaud TeamRaiser
- 16.4K Blackbaud Raiser's Edge NXT®
- 4.1K SKY Developer
- 547 ResearchPoint™
- 151 Blackbaud Tuition Management™
- 1 YourCause® from Blackbaud®
- 61 everydayhero
- 3 Campaign Ideas
- 58 General Discussion
- 115 Blackbaud ID
- 87 K-12 Blackbaud ID
- 6 Admin Console
- 949 Organizational Best Practices
- 353 The Tap (Just for Fun)
- 235 Blackbaud Community Feedback Forum
- 55 Admissions Event Management EAP
- 18 MobilePay Terminal + BBID Canada EAP
- 36 EAP for New Email Campaigns Experience in Blackbaud Luminate Online®
- 109 EAP for 360 Student Profile in Blackbaud Student Information System
- 41 EAP for Assessment Builder in Blackbaud Learning Management System™
- 9 Technical Preview for SKY API for Blackbaud CRM™ and Blackbaud Altru®
- 55 Community Advisory Group
- 46 Blackbaud Community Ideas
- 26 Blackbaud Community Challenges
- 7 Security Testing Forum
- 1.1K ARCHIVED FORUMS | Inactive and/or Completed EAPs
- 3 Blackbaud Staff Discussions
- 7.7K ARCHIVED FORUM CATEGORY [ID 304]
- 1 Blackbaud Partners Discussions
- 1 Blackbaud Giving Search™
- 35 EAP Student Assignment Details and Assignment Center
- 39 EAP Core - Roles and Tasks
- 59 Blackbaud Community All-Stars Discussions
- 20 Blackbaud Raiser's Edge NXT® Online Giving EAP
- Diocesan Blackbaud Raiser’s Edge NXT® User’s Group
- 2 Blackbaud Consultant’s Community
- 43 End of Term Grade Entry EAP
- 92 EAP for Query in Blackbaud Raiser's Edge NXT®
- 38 Standard Reports for Blackbaud Raiser's Edge NXT® EAP
- 12 Payments Assistant for Blackbaud Financial Edge NXT® EAP
- 6 Ask an All Star (Austen Brown)
- 8 Ask an All-Star Alex Wong (Blackbaud Raiser's Edge NXT®)
- 1 Ask an All-Star Alex Wong (Blackbaud Financial Edge NXT®)
- 6 Ask an All-Star (Christine Robertson)
- 21 Ask an Expert (Anthony Gallo)
- Blackbaud Francophone Group
- 22 Ask an Expert (David Springer)
- 4 Raiser's Edge NXT PowerUp Challenge #1 (Query)
- 6 Ask an All-Star Sunshine Reinken Watson and Carlene Johnson
- 4 Raiser's Edge NXT PowerUp Challenge: Events
- 14 Ask an All-Star (Elizabeth Johnson)
- 7 Ask an Expert (Stephen Churchill)
- 2025 ARCHIVED FORUM POSTS
- 322 ARCHIVED | Financial Edge® Tips and Tricks
- 164 ARCHIVED | Raiser's Edge® Blog
- 300 ARCHIVED | Raiser's Edge® Blog
- 441 ARCHIVED | Blackbaud Altru® Tips and Tricks
- 66 ARCHIVED | Blackbaud NetCommunity™ Blog
- 211 ARCHIVED | Blackbaud Target Analytics® Tips and Tricks
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- Luminate CRM DC Users Group
- 225 ARCHIVED | Blackbaud eTapestry® Tips and Tricks
- 1 Blackbaud eTapestry® Know How Blog
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)
- 1 Blackbaud K-12 Education Solutions™ Blog
- 280 ARCHIVED | Mixed Community Announcements
- 3 ARCHIVED | Blackbaud Corporations™ & Blackbaud Foundations™ Hosting Status
- 1 npEngage
- 24 ARCHIVED | K-12 Announcements
- 15 ARCHIVED | FIMS Host*Net Hosting Status
- 23 ARCHIVED | Blackbaud Outcomes & Online Applications (IGAM) Hosting Status
- 22 ARCHIVED | Blackbaud DonorCentral Hosting Status
- 14 ARCHIVED | Blackbaud Grantmaking™ UK Hosting Status
- 117 ARCHIVED | Blackbaud CRM™ and Blackbaud Internet Solutions™ Announcements
- 50 Blackbaud NetCommunity™ Blog
- 169 ARCHIVED | Blackbaud Grantmaking™ Tips and Tricks
- Advocacy DC Users Group
- 718 Community News
- Blackbaud Altru® Hosting Status
- 104 ARCHIVED | Member Spotlight
- 145 ARCHIVED | Hosting Blog
- 149 JustGiving® from Blackbaud® Blog
- 97 ARCHIVED | bbcon® Blogs
- 19 ARCHIVED | Blackbaud Luminate CRM™ Announcements
- 161 Luminate Advocacy News
- 187 Organizational Best Practices Blog
- 67 everydayhero Blog
- 52 Blackbaud SKY® Reporting Announcements
- 17 ARCHIVED | Blackbaud SKY® Reporting for K-12 Announcements
- 3 Luminate Online Product Advisory Group (LO PAG)
- 81 ARCHIVED | JustGiving® from Blackbaud® Tips and Tricks
- 1 ARCHIVED | K-12 Conference Blog
- Blackbaud Church Management™ Announcements
- ARCHIVED | Blackbaud Award Management™ and Blackbaud Stewardship Management™ Announcements
- 1 Blackbaud Peer-to-Peer Fundraising™, Powered by JustGiving® Blogs
- 39 Tips, Tricks, and Timesavers!
- 56 Blackbaud Church Management™ Resources
- 154 Blackbaud Church Management™ Announcements
- 1 ARCHIVED | Blackbaud Church Management™ Tips and Tricks
- 11 ARCHIVED | Blackbaud Higher Education Solutions™ Announcements
- 7 ARCHIVED | Blackbaud Guided Fundraising™ Blog
- 2 Blackbaud Fundraiser Performance Management™ Blog
- 9 Foundations Events and Content
- 14 ARCHIVED | Blog Posts
- 2 ARCHIVED | Blackbaud FIMS™ Announcement and Tips
- 59 Blackbaud Partner Announcements
- 10 ARCHIVED | Blackbaud Impact Edge™ EAP Blogs
- 1 Community Help Blogs
- Diocesan Blackbaud Raiser’s Edge NXT® Users' Group
- Blackbaud Consultant’s Community
- Blackbaud Francophone Group
- 1 BLOG ARCHIVE CATEGORY
- Blackbaud Community™ Discussions
- 8.3K Blackbaud Luminate Online® & Blackbaud TeamRaiser® Discussions
- 5.7K Jobs Board