delete cq_cic_complaint_action
where rowid in
(select therowid from
(select rowid therowid, a.action_date, a.action_index, a.file_date,
       row_number() over (partition by action_date, action_index order by file_date)
    as rowident
from cq_cic_complaint_action a
where (action_index, action_date) in
(select distinct action_index, action_date
 from (select action_index, action_date, count(*)
       from   cq_cic_complaint_action b
       group by action_index, action_date
       having count(*) > 1)))
where rowident=2)
