首页 > 数据库技术 > 详细

oracle 去掉重复的数据

时间:2020-08-11 22:10:04      阅读:63      评论:0      收藏:0      [点我收藏+]

原理

根据id,count(id),查出需要去重id,去掉id,

具体可以为

select * from 表名 where id not in (select id ,count(id) from 表名 group by id having count(id)>1)

当然表名也可以为结果集

select  *  from (
with t AS (
SELECT id,pqmc,to_char(pqdd) AS aa from uf_pqjzb WHERE pqdd IS NOT NULL --AND ID =‘57‘ 
)
select id,pqmc,regexp_substr(aa, [^,]+, 1, level) as pqdd
 
from t 
 
connect by level <= regexp_count(aa, \,\) + 1
 
and aa = prior aa
 
and prior dbms_random.value > 0

)  a where a.pqdd NOT in (SELECT pqdd FROM (
with t AS (
SELECT id,pqmc,to_char(pqdd) AS aa from uf_pqjzb WHERE pqdd IS NOT NULL --AND ID =‘57‘ 
)
select id,pqmc,regexp_substr(aa, [^,]+, 1, level) as pqdd
 
from t 
 
connect by level <= regexp_count(aa, \,\) + 1
 
and aa = prior aa
 
and prior dbms_random.value > 0)  GROUP BY pqdd HAVING COUNT(pqdd)>1)

 

oracle 去掉重复的数据

原文:https://www.cnblogs.com/chenzhelove/p/13485188.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!