SQL篩選重復數據的方法有多種,下面列舉了幾種常用的方法:
SELECT column1, column2, COUNT(*) as count
FROM table
GROUP BY column1, column2
HAVING COUNT(*) > 1;
SELECT column1, column2
FROM table
WHERE column2 IN (
SELECT column2
FROM table
GROUP BY column2
HAVING COUNT(*) > 1
);
WITH cte AS (
SELECT column1, column2, ROW_NUMBER() OVER(PARTITION BY column1, column2 ORDER BY column1) AS rn
FROM table
)
SELECT column1, column2
FROM cte
WHERE rn > 1;
以上是幾種常用的方法,根據具體情況選擇合適的方法進行篩選。