select a.xsbm,a.zcsl from tablename as a,(select xsbm,max(lsh) as lsh from tablename where jzshbz=2 group by xsbm) as b
where a.jzshbz=2
and a.xsbm=b.xsbm
and a.lsh=b.lsh

解决方案 »

  1.   

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

  2.   

    8992026(8992026)写的好象有点问题,
    本人建了个表测试过。下面的脚本测试过,你试一下:
    SELECT DISTINCT xsbm AS xsbm,
              (SELECT MAX(lsh)
             FROM table2 b
             WHERE a.xsbm = b.xsbm) AS MaxLsh, zcsl AS zcsl, jzshbz AS jzshbz
    FROM TABLE2 a
    WHERE (zcsl = 2)将TABLE2换成你的表名。
      

  3.   

    8992026(8992026) 的写法正确,是不是哪位高手的化名啊?gzj0815(wy) 的语句可能有些问题,因为没有做分组,语句执行的时候会报错的。