I'm currently working on a site that uses aMember to manage payments for a WordPress site, to enforce the paywall. I was not the admin that set it up, and I am still learning my way around their database. Additionally, my SQL-fu is weak; I'm not an engineer by training but I'm the only one in the organization who knows any SQL at all.
My CFO wants a report that breaks down the number of new registrations by day, going back two years. To the best of my knowledge, aMember does not have a simple breakdown of this. What it DOES have is a complete record of every payment we have ever received.
I can easily break down this payment record by date to see how many payments we got on a given date. The trouble is, many of these payments are from existing users. Additionally, we have users that have subscribed, cancelled, then re-subscribed. Our threshold for this is 30 days, since we consider that a "full lapse". So, we want to ignore any payments made on [date] by users having a payment that has expired within 30 days of [date].
example: John Smith subscribed on 12/1/2012. John Smith's last payment expired on 1/1/2013. John's account does not renew. John resubscribed on 1/5/2013. John's payment should be counted as "new" on 12/1/2012 (since he had no prior payments on record), but not on 1/5/2013 (because he had a payment expire on 1/1, within 30 days of the 1/5 payment).
the schema is below. the current query, that does NOT filter out existing members renewing and is only a count of payments received, is as follows. if any additional information is needed, or someone has knowledge of aMember beyond my own, please let me know what else I can provide to facilitate an answer. I am in over my head and doing my best!
SELECT begin_date, COUNT( payment_id )
FROM [foo]
WHERE amount >0
GROUP BY begin_date
ORDER BY begin_date DESC
payment_id
member_id
product_id
begin_date
expire_date
paysys_id
receipt_id
amount
completed
remote_addr
data
time