要找出重復數據,可以使用以下方法:
SELECT column1, column2, COUNT(*) AS count
FROM table_name
GROUP BY column1, column2
HAVING count > 1;
SELECT column1, column2
FROM table_name
WHERE (column1, column2) IN (
SELECT column1, column2
FROM table_name
GROUP BY column1, column2
HAVING COUNT(*) > 1
);
WITH cte AS (
SELECT column1, column2, ROW_NUMBER() OVER (PARTITION BY column1, column2 ORDER BY column1) AS rn
FROM table_name
)
SELECT column1, column2
FROM cte
WHERE rn > 1;