我正在使用 postgreSQL 9.1,我想使用此提示从表中删除重复项: https ://stackoverflow.com/a/3822833/2239537
所以,我的查询看起来像这样:
WITH cte
AS (SELECT ROW_NUMBER()
OVER (PARTITION BY code, card_id, parent_id
ORDER BY id DESC) RN
FROM card)
DELETE FROM cte
WHERE RN > 1
但它告诉我
ERROR: relation "cte" does not exist
SQL state: 42P01
Character: 157
但是,此语句工作正常:
WITH cte
AS (SELECT ROW_NUMBER()
OVER (PARTITION BY code, card_id, parent_id
ORDER BY id DESC) RN
FROM merchantcard)
SELECT * FROM cte
WHERE RN > 1
任何想法如何让它工作?谢谢!