Skip to content

1126. Active Businesses 👍

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
WITH
  AvgEvents AS (
    SELECT
      business_id,
      AVG(occurences) OVER(PARTITION BY event_type) AS event_avg_occurences,
      occurences
    FROM Events
  )
SELECT business_id
FROM AvgEvents
GROUP BY 1
HAVING SUM(IF(occurences > event_avg_occurences, 1, 0)) > 1;