select * from tbname where (bh,cs) in (select bh,max(cs) from tbname group by bh);

解决方案 »

  1.   

    select * from tbname where (bh,cs) in (select bh,max(cs) from table1 group by bh)
    同意樓上的看法
      

  2.   

    再问一下:
    如何获得最大次数对应的suss是0的记录,比如上面要求得到以下结果:
    bh suss cs
    3   0    1
    3   0    2
    4   0    1
      

  3.   

    select * from tbname where (bh,cs) in (select bh,max(cs) from tbname group by bh)
    and suss =0;
      

  4.   

    to njypch(七世倾情):
    你的结果不对,你可以口头算一下,要求结果如下:bh suss cs
    3   0    1
    3   0    2
    4   0    1
      

  5.   

    你写的要求效率吗?如果用in可就无效率可言了.
    select bh , suss, max(cs) from table1 where suss = 0 group by bh , suss