Query to find all bars that sell three different beers at the same price

Posted by Eternal Learner on Stack Overflow See other posts from Stack Overflow or by Eternal Learner
Published on 2010-05-03T18:56:51Z Indexed on 2010/05/03 19:08 UTC
Read the original article Hit count: 189

Filed under:
|
|

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 ?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about mysql-query