Hi I have a database with a column containing email addresses and a second column containing category and a third column containing date.
What I want to do is count the number of unique email addresses in category 'A' between multiple date ranges. So I have this:
SELECT COUNT(DISTINCT email) as counter
FROM table
WHERE category = "A" AND date < "2015-12" AND date > "2015-11";
Then I'll do a separate query for the second date range.
NOW HERE'S MY PROBLEM:
If an email address appears in month one, and also in month two it will go on the count for both months because it's unique within the range I'm querying.
How do I create a query that will count the unique email addresses for a year let's say, then count the distinct entries in a month period without including the duplicates?
Thanks!