select a.* from 表 a where not exists(select 1 from 表 where xno=a.xno and id>a.id)

解决方案 »

  1.   

    --楼主列出的结果是不是有错误?
    select id=max(id),xno from yourtable group by xno
    --result
       id   xno
       3     2
       4     3
      

  2.   

    wzh1215(懒猫) 
       --楼主列出的结果是不是有错误?
    ------------------大哥,谢谢你的回答,
    我的结果没有错误,我是在写程序的过程中,
    如果,在第3组中,有两个人的评审级别都是4,
    那么在这两个人的“待办事宜”都要出现跟自已相关的一条记录!
    不知大哥出没有搞清楚我的意思?????  
     
      

  3.   

    select a.id,a.xno
    from 表名 a inner join 
    (select max(id) as max_id,xno from 表名 group by xno ) b on a.id=b.max_id and a.xno=b.xno
    order by a.id
      

  4.   


    create table #TP ( id int null , xno int null )insert #TP ( id , xno ) values ( 1 , 2 )
    insert #TP ( id , xno ) values ( 3 , 2 )
    insert #TP ( id , xno ) values ( 2 , 2 )
    insert #TP ( id , xno ) values ( 1 , 3 )
    insert #TP ( id , xno ) values ( 2 , 3 )
    insert #TP ( id , xno ) values ( 3 , 3 )
    insert #TP ( id , xno ) values ( 4 , 3 )
    insert #TP ( id , xno ) values ( 4 , 3 )select a.id,a.xno
    from #TP a inner join 
    (select max(id) as max_id,xno from #TP group by xno ) b on a.id=b.max_id and a.xno=b.xno
    order by a.iddrop table #TP