Hi,
I am trying to find a query that will make up a report of expired members during a period.
I have a report that shows active members during a period.
What is happening is people that have renewed their membership are showing on both the active and expired report. I think this is because a user that has renewed their membership will have a subscription record for every time that they renew their membership. So the query gets the Active record to show on the active report, but it gets the previous now expired record and shows the user on the expired report.
Here is the query that I am using:
SELECT cb.lastname, cb.firstname, cbp.name, cbs.status, cbs.expiry_date, u.email, cb.cb_phone, cb.cb_address, cb.cb_city, cb.cb_province, cb.cb_postalcode, cb.cb_country FROM #__comprofiler As cb
LEFT JOIN #__users AS u ON u.id=cb.user_id
LEFT JOIN #__cbsubs_subscriptions AS cbs ON cbs.user_id=cb.user_id
LEFT JOIN #__cbsubs_plans AS cbp ON cbs.plan_id=cbp.id
LEFT JOIN #__user_usergroup_map AS ugm ON cb.user_id=ugm.user_id
WHERE ugm.group_id=2 AND cbs.status = 'X' AND cbs.plan_id > 0
AND cbs.expiry_date > '2015-02-01 09:13:35'
AND cbs.expiry_date < '2015-03-11 09:13:39'
ORDER BY cbs.expiry_date DESC, cb.lastname ASC, `cb`.`firstname` asc LIMIT 0, 100
What do I need to do in order to only find the user's latest subscription record and check it instead of checking all of their subscription record. That is how to I find only users that have expired and not renewed?
Thank you for your help on this.