浏览 2794 次
锁定老帖子 主题:oracle查询重复记录
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-07-07
1.操作单个字段: SELECT * FROM aj_xyrxx t1 WHERE t1.ajbh IN (SELECT t2.ajbh FROM aj_xyrxx t2 GROUP BY t2.ajbh HAVING COUNT(t2.ajbh) > 1) ;
DELETE FROM aj_xyrxx t1 WHERE t1.ajbh IN (SELECT t2.ajbh FROM aj_xyrxx t2 GROUP BY t2.ajbh HAVING COUNT(t2.ajbh) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM aj_xyrxx t3 GROUP BY t3.ajbh HAVING COUNT(t3.ajbh) > 1) ;
SELECT * FROM aj_xyrxx t1 WHERE (t1.ajbh,t1.rybh) IN (SELECT t2.ajbh,t2.rybh FROM aj_xyrxx t2 GROUP BY t2.ajbh,t2.rybh HAVING COUNT(*) > 1) ; b.删除
DELETE FROM aj_xyrxx t1 WHERE (t1.ajbh,t1.rybh) IN (SELECT t2.ajbh,t2.rybh FROM aj_xyrxx t2 GROUP BY t2.ajbh,t2.rybh HAVING COUNT(*) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM aj_xyrxx t3 GROUP BY t3.ajbh,t3.rybh HAVING COUNT(*) > 1) ;
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |