select top 10 * from test a where (select count(*) from test where comname=a.comname and id>a.id)<1 select top 10 a.* from test a inner join ( select min(id) as [id],comname ……