I have a question on how the less than operator is used in this SQL query that answers the following English statement:
Drinkers who frequent at least two bars
NOTE: there is a table called frequents with columns of drinker and bar.
Now, I solved this originally by utilizing the group by
and having count
operators, but I have stumbled upon this query which also is correct:
SELECT DISTINCT f1.drinker
FROM frequents f1, frequents f2
WHERE f1.drinker = f2.drinker
AND f1.bar < f2.bar
I am having a little trouble understanding the mechanics of this query, specifically with the final AND statement.