I have a mysql row that I am trying to get distinct number of email addresses grouped by province. And it seems to be giving weird values.
If I do the following (count distinct email addresses for province) for each province
SELECT COUNT(DISTINCT(email_address)) as COUNT
FROM entries
WHERE subscribe='1'
AND province='ns'
and add them all up. I get a number that is roughly 200 more then if I just do
SELECT COUNT(DISTINCT(email_address)) as COUNT
FROM entries
WHERE subscribe='1'
which also matches
SELECT COUNT(DISTINCT(email_address)) as COUNT
FROM entries
WHERE subscribe='1'
AND province IN('ns','nb','pei')
but doesn't match
SELECT COUNT(DISTINCT(email_address)) as COUNT
FROM entries
WHERE subscribe='1'
GROUP BY province
if I do
SELECT COUNT(DISTINCT(email_address)) as COUNT
FROM entries
WHERE subscribe='1'
So the 2nd one and the 4th one match, and the 1st and 3rd and 5th ones match. But the 2nd/4th is 200 more then the 1st/3rd/5th.
All I want is number of distinct email addresses where subscribe is 1 grouped by province. And it seems to be impossible to get.