一张表里字段 A B C D
A是流水号
B,C字段都是一样的
D字段不一样我现在要取流水号最大的一条
但是group by  查询 D字段不同的都查询出来了 
我想要达到的效果是A  B  C  D
1  2   2  3
2  2   2   4
3   3  3   5
4   3   3   6查询出来 应该是  
2   2   2  4
4   3   3   6
只取流水号大的那条

解决方案 »

  1.   

    select * from tb a where not exists(select 1 from tb where id>a.id)
      

  2.   

    select * from tb a where not exists(select 1 from tb where A>a.A)
    select * from tb where A=(select max(A) from tb)
      

  3.   


    一位大哥....select * from tb where A in(select max(A) from tb)
      

  4.   

    select * from tb t id=(select max(id) from tb where b=t.b and c.t.c)