I have quite a large DB, but I've simplified it for the purpose of this question:
Basically, every time a user clicks something on my site, it gets logged as a row in my DB: the UserID
field is a cookie that is used to identify the user, and Stuff
and MoreStuff
are data about the click. Note that, obviously, these are likely to be different every time, "Foo" and "Bar" is just a representation.
What I want to do is this: with an SQL query, filter out either all of the first visits, or all of the repeated visits (I assume if I can do one, I can invert my filter for the other). So, if I were to filter out all of the repeat visits on my sample, I'd get this:
with green representing the selected rows and red representing the rejected ones.
How can I do this with just SQL?