I have a script to count distinct id for registration once per year
SELECT COUNT(DISTINCT id),
MONTH(reg_date), YEAR(reg_date)
FROM reg_tbl
WHERE YEAR(reg_date) IN (2013, 2014, 2015)
I want to have the data count each id
only once per year even if it is returned more than once. I would also like the id to be counted in the maximum month it was registered. That is, if the id
is registered in January, February and March of a specific year I would like it to be counted once but within the month of the latest registration.