少年阿賓

          那些青春的歲月

            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
          主站蜘蛛池模板: 盐边县| 德惠市| 阳高县| 浮山县| 南岸区| 隆林| 台安县| 公安县| 普兰县| 太和县| 开封市| 桂林市| 金秀| 庆阳市| 秦皇岛市| 合江县| 孟州市| 武冈市| 曲阳县| 蒲城县| 陆良县| 云霄县| 宝应县| 泾川县| 明水县| 时尚| 福贡县| 太谷县| 巩留县| 玉溪市| 拉萨市| 绿春县| 临猗县| 德兴市| 南宁市| 绵阳市| 四川省| 新化县| 太康县| 安远县| 邮箱|