SQL数据去重的方法有以下几种:
例如:SELECT DISTINCT column1, column2 FROM table_name;
例如: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, column2) AS rn
FROM table_name
)
SELECT column1, column2
FROM CTE
WHERE rn = 1;
例如:
SELECT column1, column2
FROM table_name t1
WHERE NOT EXISTS (
SELECT 1
FROM table_name t2
WHERE t1.column1 = t2.column1
AND t1.column2 = t2.column2
AND t1.id != t2.id
);
以上是SQL数据去重的几种常用方法,可以根据具体情况选择适合的方法来去除重复数据。