表table有列如下:
bh  /*编号*/
id都是int值,bh值唯一,id值依次+1
设有以下数值bh  id
001 1
001 2
001 3
002 1
002 2
002 3
002 4
002 5
003 1
003 2
003 3
.....
.....
010 9我想查询的是,找出所有编号id值最大的那行。。

解决方案 »

  1.   


    SELECT * FROM TABLE T WHERE EXISTS(select * from table where bh=t.bh and id<t.id)
      

  2.   

    select * from tb t where not exists(select 1 from tb where bh=t.bh and id>t.id)
      

  3.   

    select bh,max(id) as id from tab group by  bh
      

  4.   

    可惜哥哥的SQL Server尚未学习完毕,待我学成归来,一定帮你搞定一切
    QQ 124964132