[Solved] Print name of all activities with neither maximum nor minimum number of participants

[ad_1]

You can use window functions if your mysql version is 8 or above

select activity from (select activity, count(*) as cnt,
                             max(count(*)) over () as maximum_cnt,
                             min(count(*)) over () as minimum_cnt
                        from friends group by activity) mytable
where cnt not in (maximum_cnt, minimum_cnt);

4

[ad_2]

solved Print name of all activities with neither maximum nor minimum number of participants