with t as (select event_type, avg(occurences) avg_ocrfrom Eventsgroup by event_type)-- solution 1select business_idfrom Events left join t using(event_type)group by business_idhavingsum(occurences > avg_ocr) >=2-- solution 2select business_idfrom Events inner join t on Events.event_type=t.event_type and Events.occurences > t.avg_ocrgroup by1havingcount(1) >=2