要求只from一次(不带join),拿到满足“80分以上的学生超过两名且平均分超过60分”的每个班级

 

select t.class
from table_name t
where t.class in (
    select cc.class from (
        select a.class,count(a.username) count from table_name a
                where a.pcrioermance > 80
                group by a.class) as cc where count > 2)
group by t.class
having avg(t.pcrioermance) > 60;

抱歉我能力有限 只能写成这个样子了,希望能帮到你