SQLServer 数据去重高效方法
数据去重高效方法
去重的方法有很多,比如用什么Distinct、 Group By Having、临时表等
有兴趣的朋友可以把各种方法对比一下得出直观的效率概况
WITH TEST AS
(
SELECT ROW_NUMBER()
OVER(PARTITION BY Column1,Column2,Column3 ORDER BY ID )
AS NUM,* FROM TableName
)
DELETE FROM TEST
WHERE NUM != 1
(
SELECT ROW_NUMBER()
OVER(PARTITION BY Column1,Column2,Column3 ORDER BY ID )
AS NUM,* FROM TableName
)
DELETE FROM TEST
WHERE NUM != 1
百万数据量一分左右(当然也要看机器配置)
---------------------------------------------------------------------
mysql应该是不能执行的。。所以我是说这是纯摘抄而已