DELETE FROM sim_article_candidate
WHERE third_articleid IN (
SELECT third_articleid
FROM (
SELECT third_articleid
FROM sim_article_candidate
WHERE imp_date = 20200601
GROUP BY third_articleid
HAVING COUNT(third_articleid) > 1
) a
)
AND flowid NOT IN (
SELECT flowid
FROM (
SELECT MAX(flowid) AS flowid
FROM sim_article_candidate
WHERE imp_date = 20200601
GROUP BY third_articleid
HAVING COUNT(third_articleid) > 1
) b
);