PostgreSQL 查询表中重复数据

1)查询表中重复数据

SELECT * FROM "tbScenics"
WHERE "Scenic_Id"
NOT IN (
SELECT max("Scenic_Id")
FROM "tbScenics"
GROUP BY  "Scenic_Name", "Scenic_Des", "Scenic_Price", "Scenic_Ticket"

);

2)删除表中重复数据
DELETE * FROM "tbScenics"
WHERE "Scenic_Id"
NOT IN (
SELECT max("Scenic_Id")
FROM "tbScenics"
GROUP BY  "Scenic_Name", "Scenic_Des", "Scenic_Price", "Scenic_Ticket"
);

你可能感兴趣的:(PostgreSQL)