题目来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/activity-participants
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
本人思路:
– 1、本题题意很简单,即按activity分组,并找到计数再min和max之间
– 2、因为between …and 是包含两个边界的,所以min+1,max-1是为了去掉between and的边界值
select activity
from Friends
group by activity
having count(id)
between (select count(id) as num from friends group by activity order by num limit 0,1)+ 1
and (select count(id)as num from friends group by activity order by num desc limit 0,1)- 1