id c1 c2
1 10 5
2 5 10
3 4 9
4 9 4
现在的需求是,对于c1和c2进行去重,,比如第一行和第二行记录分别是10和5、5和10,则只取id大的那行记录。
3 个解决方案
#2
版主也太给力啦
#3
楼上给的是去除同列重复的,这个是交叉列重复
select * from t
where (c1,c2) not in (
select t2.c2,t2.c1 from t t2 join t t3 on t3.c1=t2.c2 where t2.id>t3.id
);
#1
#2
版主也太给力啦
#3
楼上给的是去除同列重复的,这个是交叉列重复
select * from t
where (c1,c2) not in (
select t2.c2,t2.c1 from t t2 join t t3 on t3.c1=t2.c2 where t2.id>t3.id
);