一张表有十万数据,字段名为a,b,c, 如果a字段的属性值样,就查找它的前五行,求解高手……

解决方案 »

  1.   

    属性值?什么是属性值?就是a字段的值一样的呗?这样的么?取前五行?
    a b c
    1 2 3 
    1 4 5 
    1 6 7 
    1 8 9 
    1 ww qq 
      

  2.   


    select tt.a,tt.b,tt.num
    from (
    select t.a,t.b,ROW_NUMBER() over(partition by t.a order by t.a) num
    from test t
    group by t.a,t.b)tt
    where tt.num < 6
      

  3.   

    tt就是它
    select t.a,t.b,ROW_NUMBER() over(partition by t.a order by t.a) num
    from test t
    group by t.a,t.b