with CTE AS
(
select AGENT_USERID,
ROW_NUMBER() OVER(PARTITION BY AGENT_USERID ORDER BY (agent_USERID)) AS RN
FROM KYCKEN.PAP_KYCAGENTCONFIG
)
DELETE FROM CTE where RN > 1
我收到运行查询时需要语句的错误。之前没有代码。使用查询删除重复项。选择代替删除工作正常,但使用删除抛出错误。
答案 0 :(得分:0)
Linux / Unix / Windows的Db2接受以下语法:
with cte as
(
select agent_userid
,row_number() over (partition by agent_userid order by (agent_userid)) as rn
from kycken.pap_kycagentconfig
)
select agent_userid as agent_userid_to_delete
from old table
( delete from kycken.pap_kycagentconfig
where agent_userid in (select agent_userid from cte where rn > 1)
)
;
答案 1 :(得分:0)
在DB2上,尝试类似这样的事情:
DELETE FROM KYCKEN.PAP_KYCAGENTCONFIG f0
where rrn(f0) in
(
select f2.rnwrite
from (
select f1.AGENT_USERID, rrn(f1) rnwrite,
ROWNUMBER() OVER(PARTITION BY f1.AGENT_USERID ORDER BY f1.agent_USERID) AS RN
FROM KYCKEN.PAP_KYCAGENTCONFIG f1
) f2
where f2.RN>1
)