首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

orcale 剔除重复

2012-08-03 
orcale 删除重复select tid,tname ,rowid from t_temp_test select tid,tname ,max(rowid) from t_temp_t

orcale 删除重复
select tid,tname ,rowid from t_temp_test ; 
select tid,tname ,max(rowid) from t_temp_test   group by tid,tname;

delete from t_temp_test t1 where rowid not in  
  ( select max(rowid) from t_temp_test  t2  where t1.tid=t2.tid
  and t1.tname=t2.tname);

insert into t_temp_test(tid,tname) values('0001','lisi');
insert into t_temp_test(tid,tname) values('0001','lisi');
insert into t_temp_test(tid,tname) values('0001','lisi');
insert into t_temp_test(tid,tname) values('0001','lisi');
insert into t_temp_test(tid,tname) values('0001','lisi');
insert into t_temp_test(tid,tname) values('0002','zhangsan');
insert into t_temp_test(tid,tname) values('0002','zhangsan');
insert into t_temp_test(tid,tname) values('0002','zhangsan');
insert into t_temp_test(tid,tname) values('0002','zhangsan');

select * from t_mm_dir_info

delete from employee e2 where rowid not in (
  select max(e1.rowid) from employee e1 where 
 e1.emp_id=e2.emp_id and e1.emp_name=e2.emp_name and e1.salary=e2.salary);--这里用min(rowid)也可以。



select * from t_temp_test where rownum > 5

热点排行