--没有考虑性能
select a,b,c,d,e from tablename
where (a,b,c) in (
select a,b,c,max(d),max(e) tablename group by a,b,c);

解决方案 »

  1.   

    select a,b,c,d,e from tablename
    where (a,b,c,d,e) in (
    select a,b,c,max(d),max(e) from tablename group by a,b,c);
      

  2.   

    用group by就行
    select a,b,c,count(d)+count(e) from tablename group by a,b,c;
      

  3.   

    真是晕头,
    select a,b,c,max(d),max(e) from tablename group by a,b,c
      

  4.   

    jlandzpa(欧高黎嘉陈) ,jiezhi(相逢何必曾相识) :
    不对呀,这样求出来的D E是取的最大值,但他们不一定是同一条记录的值。
      

  5.   

    select a.a,a.b,a.c,a.d,max(b.e) from (select a,b,c,max(d) as d from tablename group by a,b,c) a,tablename b where a.a=b.a and a.b=b.b and a.c=b.c and a.d=b.d group by a.a,a.b,a.c,a.d
    没测试,你自己测一下吧。
      

  6.   

    select a,b,c,d,e from tablename 
    where rowid in (select x.riw from 
    (select a,b,c,max(rowid) riw from tablename group by a,b,c) x 
    );
      

  7.   

    select a,b,c,d,e from tablename 
    where rowid in (select x.riw from 
    (select a,b,c,max(rowid) riw from tablename group by a,b,c) x 
    );
      

  8.   

    jlandzpa(欧高黎嘉陈) :select a,b,c,max(d),max(e) from tablename group by a,b,c;
    贴主:
    不对呀,这样求出来的D E是取的最大值,但他们不一定是同一条记录的值。我认为:
    jlandzpa是对的,首先,你要达到的目的是什么?是a,b,c不重复,其次是d,e随便取一条。这样的话,group by a,b,c保证不重复,而在a,b,c重复(注意!!)的记录中任取一条(那么取成最大值也无所谓了)。可以达到你的目的就行了啊。
      

  9.   

    snowy_howe(天下有雪) :
    抱歉,是我没有说清楚,所以造成理解上的偏差。我的确实要d e为同一条记录。
    非常感谢各位的帮助。