当前位置:Gxlcms > mysql > 删除表中重复记录大于两条保存两条

删除表中重复记录大于两条保存两条

时间:2021-07-01 10:21:17 帮助过:31人阅读

delete from t_Cht_clm_reg F where F.case_id in ( select T.case_id from ( select B.* from (select e.* , row_number() over (partition by e.notice_id order by e.case_id desc) rn from t_Cht_clm_reg e) B where B.notice_id in( select A.notice_id

delete from t_Cht_clm_reg F where F.case_id in (
select T.case_id from (
select B.* from (select e.* , row_number() over (partition by e.notice_id order by e.case_id desc) rn
from t_Cht_clm_reg e) B where B.notice_id in(
select A.notice_id from (select e.* , row_number() over (partition by e.notice_id order by e.case_id desc) rn
from t_Cht_clm_reg e) A group by A.notice_id having count(A.notice_id) > 2 )
) T where T.RN > 2 )

<无>
  1. delete from t_Cht_clm_reg F where F.case_id in (
  2. select T.case_id from (
  3. select B.* from (select e.* , row_number() over (partition by e.notice_id order by e.case_id desc) rn
  4. from t_Cht_clm_reg e) B where B.notice_id in(
  5. select A.notice_id from (select e.* , row_number() over (partition by e.notice_id order by e.case_id desc) rn
  6. from t_Cht_clm_reg e) A group by A.notice_id having count(A.notice_id) > 2 )
  7. ) T where T.RN > 2 )

人气教程排行