How do I sort contributions in our database by the most recent contribution date? When I try to search this on the database, it brings up all contributions, not just the most recent and I want to target specific members who have not donated recently. Thanks!
-
1Can you be a bit more specific. Are you using Advanced Search, or Find Contributions, and if so why doesn't setting the date field filter to just the more recent ones– petednz - fuzion ♦Commented Dec 1, 2016 at 3:04
-
What I meant by "recent" was that I was getting multiple results for many people and I wanted to only the latest contribution they had made– ErinCommented Dec 12, 2016 at 22:37
2 Answers
Summary Fields Extension may be your friend. It will create calculated fields for 'latest donation' (and many other such fields) and these are then available in eg Adv Search.
Let us know if that helps with what you are after
If I am not wrong you need a SQL Script to list all the contribution in descenting order (Recent transaction) based on a specific membership type ?
If yes, then use this SQL which will give you recent contribution record based on the membership type - so you need to know all the membership type id and replace in the membership_type_id
in the SQL below
select * from civicrm_contribution a
LEFT JOIN civicrm_membership_payment b ON a.id = b.contribution_id
LEFT JOIN civicrm_membership c ON c.id = b.membership_id
WHERE a.contribution_status_id = 2 and c.membership_type_id = 'membership_type_id'
ORDER BY a.id DESC
I guess this helps!!!