select xsbm,zcsl
from your_table a
where a.jzshbz=2
  and a.lsh=
   (select max(lsh) from your_table b
     where b.xsbm=a.xsbm and b.jzshbz=2)

解决方案 »

  1.   

    SELECT MAX(xsbm),MAX(zcsl FROM table_name WHERE jzshbz=2 GROUOP BY xsbm
      

  2.   

    试试:
    select xsbm,zcsl group by xsbm lsh=(select max(lsh) from table group by xsbm ) and jzshbz=2;
      

  3.   

    SELECT MAX(xsbm),MAX(zcsl) FROM table_name WHERE jzshbz=2 GROUP BY xsbm
      

  4.   

    哦,不好意思,是:select xsbm,zcsl from table group by xsbm lsh=(select max(lsh) from table group by xsbm ) and jzshbz=2;
      

  5.   

    SELECT MAX(xsbm),MAX(zcsl) FROM table_name WHERE jzshbz=2 GROUP BY xsbm
      

  6.   

    哦,不好意思,是:select xsbm,zcsl from table group by xsbm lsh=(select max(lsh) from table group by xsbm ) and jzshbz=2;
      

  7.   

    select xsbm,zcsl from table where lsh in (select max(lsh) from table where jzshbz=2 group by xsbm)
      

  8.   

    select xsbm, zcsl
     from your_table a
     where a.jzshbz=2
       and a.lsh=
         (select max(lsh) from your_table b
           where b.xsbm=a.xsbm and b.jzshbz=2)
      

  9.   

    哦,不好意思,是:select xsbm,zcsl from table group by xsbm lsh=(select max(lsh) from table group by xsbm ) and jzshbz=2;
      

  10.   

    SELECT MAX(xsbm),MAX(zcsl) FROM table_name WHERE jzshbz=2 GROUP BY xsbm
      

  11.   

    select xsbm,zcsl from
    table
    where (jzshbz = 2 ) and (lsh = (select max(lsh) from table where jzshbz =2))
      

  12.   

    select distinct xsbm zcsl from table_name where jzshbz=2 and lsh in 
    (select max(lsh) from table_name);
      

  13.   


    你是不是在SQL Server区发了贴?!好像那边有答案了~~~
      

  14.   

    是啊是啊。我两个都打开等着呢:)但是那个表有10万多条记录,我想找到一条效率最高的方法。另外问jsp:你的max(zcsl)有什么意义啊?
      

  15.   

    select distinct xsbm zcsl from table_name where jzshbz=2 and lsh in 
    (select max(lsh) from table_name group by xsbm);