# Miscellaneous > Structured Query Language (SQL) >  Help with an assignment

## sa74r24r

Please help me to deal with the following problem (at least in SQL or relational algebra):

Find all drinkers who frequent a bar that serves at least 2 beers they like , and one of them for at most 2$.

LIKES(drinker,beer)
FREQUENTS(drinker, bar)
SERVES(bar,beer,cost)

----------


## skhanal

It is a complicated query, your professor really likes cheap beer. I gave my "shot"

select l.drinker
from likes as l
inner join frequents as f
on l.beer = f.beer
where (select count(*) from serves as s where s.bar = l.bar and s.beer = l.beer) >= 2
and exists (select * from serves as s where s.bar =  = l.bar and s.beer = l.beer and s.cost  <=2)
and

----------


## sa74r24r

I did it slightly different, without using aggregate functions. Thank you for the provided solution.

----------

