select class,total,name from (select *,ywsc+sxsc as total from st ORDER BY total DESC) b
where
not EXISTS(select * from (select *,ywsc+sxsc as total from st ORDER BY total DESC) c where c.class=b.class and b.total < c.total GROUP BY c.class HAVING COUNT(*)>2 )
ORDER BY b.class,b.total DESC
表结构给出来