少年阿賓

          那些青春的歲月

            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 閱讀(1195) 評論(0)  編輯  收藏 所屬分類: oracle
          主站蜘蛛池模板: 襄垣县| 商河县| 广东省| 桑日县| 桃源县| 泗洪县| 观塘区| 庆安县| 夹江县| 治多县| 财经| 迁安市| 石家庄市| 韶山市| 鹰潭市| 平湖市| 馆陶县| 东乌| 红原县| 武穴市| 土默特左旗| 东安县| 南汇区| 连云港市| 顺义区| 普格县| 东方市| 孙吴县| 抚顺县| 聂荣县| 庆阳市| 洛扎县| 全南县| 清涧县| 海阳市| 井研县| 桃园县| 鲁山县| 柞水县| 江孜县| 香河县|