MYSQL删除一张表的重复数据并且保留id最大的一条

delete ss from summary_statistics ss join ( select industry_id , date , type , max(id) as maxId from summary_statistics ss group by industry_id , date , type having count(1) > 1) a on ss.industry_id = a.industry_id and ss.date = a.date and ss.type = a.type where ss.id < a.maxId

posted @ 2023-05-25 10:18  HubuSugar  阅读(158)  评论(0编辑  收藏  举报