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!
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!!!