Требуются оконные функции:
select ACTIVITY
from (select ACTIVITY, count(*) as cnt,
max(count(*)) over () as max_cnt,
min(count(*)) over () as min_cnt
from FRIENDS
group by activity
) a
where cnt not in (max_cnt, min_cnt);
Для вышеперечисленного требуется MySQL 8+. В более ранней версии это более болезненно:
select a.ACTIVITY
from (select ACTIVITY, count(*) as cnt,
max(count(*)) over () as max_cnt,
min(count(*)) over () as min_cnt
from FRIENDS
group by activity
) a join
(select min(cnt) as min_cnt, max(cnt) as max_cnt
from (select activity, count(*) as cnt
from friends
group by activity
) a
) am
on a.cnt not in (am.max_cnt, am.min_cnt);