--没有考虑性能
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);
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);
调试欢乐多
where (a,b,c,d,e) in (
select a,b,c,max(d),max(e) from tablename group by a,b,c);
select a,b,c,count(d)+count(e) from tablename group by a,b,c;
select a,b,c,max(d),max(e) from tablename group by a,b,c
不对呀,这样求出来的D E是取的最大值,但他们不一定是同一条记录的值。
没测试,你自己测一下吧。
where rowid in (select x.riw from
(select a,b,c,max(rowid) riw from tablename group by a,b,c) x
);
where rowid in (select x.riw from
(select a,b,c,max(rowid) riw from tablename group by a,b,c) x
);
贴主:
不对呀,这样求出来的D E是取的最大值,但他们不一定是同一条记录的值。我认为:
jlandzpa是对的,首先,你要达到的目的是什么?是a,b,c不重复,其次是d,e随便取一条。这样的话,group by a,b,c保证不重复,而在a,b,c重复(注意!!)的记录中任取一条(那么取成最大值也无所谓了)。可以达到你的目的就行了啊。
抱歉,是我没有说清楚,所以造成理解上的偏差。我的确实要d e为同一条记录。
非常感谢各位的帮助。