select * from xp as x where E = max(E) group by A

解决方案 »

  1.   

    select T1.* from XP as T1, (select A,B,max(E) as MAXE from XP
     group by A,B) as T2 
    where T1.A=T2.A and T1.B=T2.B and T1.E=T2.MAXE在ACCESS 2000以上版本可以通过。
      

  2.   

    faint! 上面的不对,我正在写的时候一登陆就发表了。
      

  3.   

    select * from xp where
     
    e in(select max(e) from Table1 group by a)]这样才是
      

  4.   

    select * from xp where e in (select Max(e) From xp group by a)
      

  5.   

    access我没用过,上面是Sybase的作法,参考一下吧
      

  6.   

    不用视图也可以解决。这么写
    select * from xp as X 
     where not exits
      (select * form xp as Y
        where X.a = Y.a and X.e < Y.e)
      

  7.   

    SELECT Max(xp.E) AS Max_E, xp.B, xp.A,xp.C
    FROM xp
    GROUP BY xp.B, xp.A, xp.C;
    以上语句可得到绝大部分的信息,除了D即时间;如一定要D,你可以在Delphi表中设计一个CalcField即计算字段,按照Max_E, xp.B, xp.A,xp.C四个值定位记录得到D即可.至此,xp中的A,B,C,D,E信息可以用一句SQL在一个DBGrid中列出.
      

  8.   

    我觉得是不是我的表达不太准确,我的意思是得到完整的一条记录,特别是得到字段D,
    另外:kikic99() 的方法能说明白一点吗?最好写出如何作,谢谢!
      

  9.   

    明确地说:
    kikic99的方法可能也能够实现,但是有悖于SQL语句的原意;
    chy018的方法涉及父查询和子查询之间传参,也有可能通过;
    我的方法——在一句SQL中建立并使用临时视图——百分之百能实现你的目的。其他的人都是瞎说。