select t.* from
(select sid,result=avg(result) from sturel where class<>'体育' group by sid )t,student g
where t.sid=g.sid and t.result>85 and g.grade=3
order by result desc,t.sid asc
(select sid,result=avg(result) from sturel where class<>'体育' group by sid )t,student g
where t.sid=g.sid and t.result>85 and g.grade=3
order by result desc,t.sid asc
from student a join sturel b on a.sid = b.sid
where grade = 3 and class <> '体育'
group by a.sid, a.name
having avg(b.result) > 85
order by avg(b.result) desc, a.sid