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