设你的表中有标识列为id(或者值不重复,可以比较大小的列),你限制的10条是取id最大的10条select f1,f2,f3 from t1 a where 10>(select count(1) from t1 b where b.id>a.id and a.f1=b.f1)如果你的表中没有这样的列,那只有借助临时表,用identity生成标识列,再这样做。
如果是取id最小的10条,则将 where b.id>a.id and a.f1=b.f1改为 where b.id<a.id and a.f1=b.f1
select f1,f2,f2 from tablename t1 where checksum(*) in (select top 10 checksum(*) from tablename where f1 = t1.f1) group by f1,f2,f3
where b.id>a.id and a.f1=b.f1改为
where b.id<a.id and a.f1=b.f1
where checksum(*) in (select top 10 checksum(*) from tablename where f1 = t1.f1)
group by f1,f2,f3