【发布时间】:2021-03-02 20:59:30
【问题描述】:
我在 Postgres 中使用 CTE 编写了以下查询。现在我无法从中删除记录。
WITH cte AS (
SELECT
firstname,
lastname,
country,
ROW_NUMBER() OVER (
PARTITION BY
firstname,
lastname,
country
) row_num
FROM
employee
)
delete from cte
where row_num >1
当我运行此查询时,它会显示错误:
关系“cte”不存在
这是我的表“员工”的示例
id firstname lastname country
1 "Raj" "Gupta" "India"
2 "Raj" "Gupta" "India"
3 "Mohan" "Kumar" "USA"
4 "James" "Barry" "UK"
5 "James" "Barry" "UK"
6 "James" "Barry" "UK"
【问题讨论】:
-
请提供员工表的样本数据。 :-)
-
@Linker 我已经编辑了我的问题并在其中添加了一个表员工示例。谢谢
标签: sql postgresql common-table-expression sql-delete