--try
select *
from 表 a
where m in(select top 10 m from 表 where x=a.x )

解决方案 »

  1.   

    select *
    from 表 a
    where m in(select top 10 m from 表 where x=a.x order by M)
      

  2.   

    declare @t table(x varchar(10),m varchar(20))
    insert into @t select '陈','陈1'
    union all  select '陈','陈2'
    union all  select '陈','陈3'
    union all  select '陈','陈4'
    union all  select '陈','陈5'
    union all  select '陈','陈6'
    union all  select '陈','陈7'
    union all  select '陈','陈8'
    union all  select '陈','陈9'
    union all  select '陈','陈10'
    union all  select '陈','陈11'  
    union all  select '陈','陈12'
    union all  select '陈','陈13'
    union all  select '陈','陈14'  
    union all  select '王','王1'  
    union all  select '王','王2'  
    union all  select '王','王3'  
    union all  select '王','王4'  
    union all  select '王','王5'  
    union all  select '王','王6'  
    union all  select '王','王7'  
    union all  select '王','王8'  
    union all  select '王','王9'  
    union all  select '王','王10'  
    union all  select '王','王11'  
    union all  select '王','王12'  
    union all  select '王','王13'  
    union all  select '王','王14'  
    union all  select '王','王15'  
    select *
    from @t a
    where m in (select top 10 m from @t where x=a.x order by M)/*
    x          m                    
    ---------- -------------------- 
    陈          陈1
    陈          陈2
    陈          陈3
    陈          陈4
    陈          陈5
    陈          陈10
    陈          陈11
    陈          陈12
    陈          陈13
    陈          陈14
    王          王1
    王          王2
    王          王3
    王          王4
    王          王10
    王          王11
    王          王12
    王          王13
    王          王14
    王          王15
    */
      

  3.   

    SQL语句不能实现的话存储过程也可
      

  4.   

    select top10 * from table1 where x='张'