比如有下面的表: 
a    b    c 1    1    p 
1    2    u 
1    3    y 
2    1    q 
2    2    w 
2    3    e 
要找出 列a的各种记录中 b值最大的记录
即找出 1 3 y 
      2 3 e 
谢谢

解决方案 »

  1.   


    --试一下:select a,max(b) over (partition by b order by b),c from tb_test;
      

  2.   

    select a, Max(b),c from table_name group by a;
      

  3.   

    select a,max(b) over (partition by b order by b),c from tb_test;select a,b,c from tb_test
    where b = (select max(b) from tb_test)
      

  4.   


    --手边没有工具,改一下:select a,max(b) over (partition by a),c from tb_test;
      

  5.   

    select a, Max(b),c from table_name group by a,c;
      

  6.   

    比如有下面的表: 
    a    b    c 1    1    p 
    1    2    u 
    1    3    y 
    2    1    q 
    2    2    w 
    2    3    e 
    要找出 列a的各种记录中 b值最大的记录 
    即找出 1 3 y 
          2 3 e 
    谢谢
    select
    m.a,m.b,m.c
    from
    (
    select t.*,row_number()over(partition by t.a,order by b desc) temp  from table_name t
    ) m  where temp=1