少年阿宾

那些青春的岁月

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks
select t.*,t.rowid from abin1 t;
删除重复的记录,只保留一条:
delete from abin1 t where rowid not in (select max(rowid) from abin1 s group by s.id1  );
delete from abin1 t where t.rowid not in (select min(s.rowid) from abin1 s where t.id1=s.id1 group by s.id1)
删除全部重复记录:
delete from abin1 t where t.id1 in (select s.id1 from abin1 s group by s.id1 having count(s.id1)>1 );
delete from abin1 t where exists (select * from abin1 s where t.id1=s.id1 group by s.id1 having count(s.id1)>1)
取出有重复的记录,没有重复的单条记录不取:
select * from abin1 t where t.id1 in (select s.id1 from abin1 s group by s.id1 having(count(s.id1))>1 );
select * from abin1 t where exists (select * from abin1 s where s.id1=t.id1 group by s.id1 having(count(s.id1))>1);
删除重复记录(保留一条):
delete from abin1 t where t.id1 not in(select max(s.id1) from abin1 s group by s.name1 having count(s.name1)>0);

posted on 2013-01-04 22:51 abin 阅读(1180) 评论(0)  编辑  收藏 所属分类: oracle

只有注册用户登录后才能发表评论。


网站导航: