我的数据库里面 。序号st有重复的记录,我只需要保留一条即可
37116
具体这样的删除语句如何写?
我写了一下,不知道哪里不对?
DELETE
FROM
rota2 a
WHERE
a.序号st,
a.值班日期 IN (
SELECT
序号st,
值班日期
FROM
rota2
GROUP BY
序号st,
值班日期
HAVING
COUNT (*) > 1
)
AND a.值班日期 NOT IN (
SELECT
MAX (值班日期)
FROM
rota2
GROUP BY
序号st,
值班日期
HAVING
COUNT (*) > 1
)