How can I select a COUNT based on ANOTHER ROW in the SAME TABLE so it doesn’t count duplicate values?
I want to select the COUNT(id) as TOTAL, only ONCE per email.
This is my starting point:
SELECT COUNT(id) AS total
FROM entries
WHERE tracking_code = 'test2'
What I’m trying to accomplish is something like this:
SELECT COUNT(id) AS total
FROM entries
WHERE id IN (SELECT DISTINCT email FROM entries)
Try this: