delete from employee where objuid in (
SELECT
objuid
FROM
(
SELECT
objuid
FROM
employee
WHERE
wx_id IN (
SELECT
wx_id
FROM
employee
GROUP BY
wx_id
HAVING
count(*) > 1
)
AND objuid NOT IN (
SELECT
min(objuid)
FROM
employee
GROUP BY
wx_id
HAVING
count(*) > 1
)
ORDER BY
user_name
) a)
DELETE
FROM
operate_ticket
WHERE
uuid IN (
SELECT
uuid
FROM
(
SELECT
uuid,
czpnum
FROM
operate_ticket
WHERE
czpnum IN ( SELECT czpnum FROM operate_ticket GROUP BY czpnum HAVING COUNT ( * ) > 1 )
AND uuid NOT IN ( SELECT MIN ( uuid ) FROM operate_ticket GROUP BY czpnum HAVING COUNT ( * ) > 1 )
) A
)