select * from Table1 a where 10>(select count(*) from Table1 where ClsNo=a.ClsNo and Score>a.Score) order by a.ClsNo,a.Score desc