oracle 去掉重复的数据

原理

根据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 去掉重复的数据

上一篇:SQlite3插入(insert into)多个变量--设置自动增长的字段(Python)


下一篇:C#中,将生成的Guid转换成Oracle数据类型Raw(16)