You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
D6JIEFENGMAIL/doc/sql/检查和删除重复.sql

47 lines
1.3 KiB
SQL

---检查邮件有无重复任务
select * from t_op_task where in
(
select t. from t_op_task t where t.='vc' and t. is not null group by t. having count(1)>1
)
and pl_id not in (
select min(t.pl_id) from t_op_task t where t.='vc' and t. is not null group by t. having count(1)>1
)
and =0
-----------------
delete from t_op_task where in
(
select t. from t_op_task t where t.='vc' and t. is not null and =1 group by t. having count(1)>1
)
and pl_id not in (
select min(t.pl_id) from t_op_task t where t.='vc' and t. is not null and =1 group by t. having count(1)>1
)
-------------
--最终检查
select * from t_op_seae_edi_mail sm
where ID in ( select ID
from t_op_seae_edi_mail m group by m.ID having COUNT(1)>1 )
and not In
(
select MIN()
from t_op_seae_edi_mail m group by m.ID having COUNT(1)>1
)
order by ID
----- 删除 重复
delete from t_op_seae_edi_mail
where ID in ( select ID
from t_op_seae_edi_mail m group by m.ID having COUNT(1)>1 )
and not In
(
select MIN()
from t_op_seae_edi_mail m group by m.ID having COUNT(1)>1
)