Query to find “All bars that sell three different beers at the same price?”
My Tables are
Sells(bar,beer,price) – bar – foreign Key..
Bars(name,addr) – name primary key.
I thought of something like this but that dosent seem to work …
Select A.bar As bar , B.bar as bar
From Sells AS A, Sells AS B
Where A.bar = B.bar and A.beer <> B.beer
Group By(A.beer)
Having Count(Distinct A.beer) >= 2
Is this the correct SQL query ?
I would do it this way:
In MySQL in particular, the join solution is likely to be more efficient than
GROUP BY.