I have two columns in a table: VisitorID, and URL.
An entry exists in the table for every page view a visitor makes. I’d like to see the total number of visits for each Visitor, where NONE of the URLs in a visitor’s group are LIKE “%page=checkout%”.
I’m thinking it’s something like this:
SELECT *, COUNT(*) AS TotalVisits FROM `VisitorLog` GROUP BY VisitorID HAVING `URL` NOT IN (SELECT * FROM ?? WHERE `URL` LIKE "%page=checkout%")
But I don’t entirely understand how the HAVING clause works with a sub-query, if I need a sub-query at all, etc? And how to make having negative?
And bonus points for anyone who can explain the answer so that I can do it myself next time!
Thanks,
Nick
1 Answer