sql语句是:
delete from table
where key in (select a. key key from (select * from table) a where niandu='2016' group by a. key having count(a.key) > 1)and ts not in (select max(b.ts) from (select * from table) b group by b.key having count(b.key )>1)
其中
(select * from table) a 是为了在将table当成是子集,防止you cant specify target table for update in from clause 错误。