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 )
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 )
   
 
   