Skip to content

1355. Activity Participants

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
WITH
  RankedFriends AS (
    SELECT
      activity,
      RANK() OVER(ORDER BY COUNT(id) ASC) AS rank_asc,
      RANK() OVER(ORDER BY COUNT(id) DESC) AS rank_desc
    FROM Friends
    GROUP BY 1
  )
SELECT activity
FROM RankedFriends
WHERE rank_asc > 1 AND rank_desc > 1;