DELETE
FROM
表名
WHERE
id NOT IN (
SELECT
dt.minno
FROM
(
SELECT
MIN(id) AS minno -- 表ID
FROM
表名
GROUP BY
month_id -- 分组字段
) dt
);
DELETE
FROM
表名
WHERE
id NOT IN (
SELECT
dt.minno
FROM
(
SELECT
MIN(id) AS minno -- 表ID
FROM
表名
GROUP BY
month_id -- 分组字段
) dt
);