mysql在删除数据的时候只能用简单的删除数据,所以在有条件的删除数据时需要先建一个临时表,然后再删除,如下:

 create table tmp as select min(se.start_time) as start_time
from crm_service10 se 
where se.ani in ('15626502532')
  group by se.user_id 
 having count(se.user_id) > 1
order by se.start_time desc;

DELETE from crm_service10 where start_time not in 
(select start_time from tmp)
and ani in ('15626502532');

drop table tmp; 
 
在oracle中直接删除即可,如下:
  
 

delete from crm_service10
where start_time not in
(select min(se.start_time) start_time
from crm_service10 se
where se.ani in ('15626502532')
group by se.user_id
having count(se.user_id) > 1)
and ani in ('15626502532')