I’m trying to write an SQL command that returns emails
that has the value
(track openers) and doesn’t have the value (redirect) for the column action_type
in the same table.
email countrycode action_type
[email protected] GB track openers
[email protected] GB redirect
[email protected] GB track openers
[email protected] GB redirect
[email protected] GB track openers
[email protected] GB redirect
[email protected] GB track openers <<
I have already tried this without success, it continues to show loading… without returning any results
SELECT DISTINCT LOWER(email) as `email`, `action_type`, `countrycode`
FROM `stats`
WHERE `email` NOT IN (SELECT `email` FROM `stats` WHERE `action_type` = 'redirect');
3
Answers
I would suggest aggregation:
This could also be an option. Here you look for all emails, that has action type
track openers
and for which doesn’t exists an action withredirect
action type.A slightly less verbose option