I have a sql query that is counting the number of times an ID appears in the table inside a date range
SELECT *,COUNT( id) AS member_count FROM members_history
where date_registered > '2018-09-01'
AND date_registered < '2018-12-31'
GROUP BY id ORDER BY last_name,first_name ASC
Now the problem is if a member registers for this year and the next year at the same time it is counting them twice.(As it should) BUT for this case I want to filter out by the event column and say if they are registered for the same event do not count them twice. Does this make sense? Sorry I am new to this. Let me know how I can improve.
I guess what Im trying to do is something like
SELECT *,
COUNT( id) AS member_count
FROM members_history
where date_registered > '2018-09-01' AND
date_registered < '2018-12-31' AND
event!= event
GROUP BY id
ORDER BY last_name,first_name ASC
Thank you