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.
47 lines
1.3 KiB
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
|
|
|
|
) |