少年阿賓

          那些青春的歲月

            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 閱讀(1191) 評論(0)  編輯  收藏 所屬分類: oracle
          主站蜘蛛池模板: 托克托县| 海林市| 吉安县| 万源市| 景东| 文水县| 息烽县| 神池县| 青川县| 平泉县| 文成县| 普定县| 略阳县| 高安市| 南江县| 武山县| 彩票| 微博| 新民市| 古交市| 德惠市| 容城县| 和政县| 兴义市| 枝江市| 瓦房店市| 平安县| 钦州市| 东海县| 中超| 竹溪县| 深泽县| 大悟县| 五峰| 隆安县| 玛多县| 左权县| 濉溪县| 龙陵县| 伊宁市| 沁源县|