gpt4 book ai didi

sql server 2008 删除重复项

转载 作者:行者123 更新时间:2023-12-04 22:33:58 25 4
gpt4 key购买 nike

我有这样的重复

col1, col2
1, alex
1, alex
2, liza
2, liza
3, peter
3, peter

每个只有两个。我如何删除重复项?

最佳答案

WITH    q AS
(
SELECT *,
ROW_NUMBER() OVER (PARTITION BY col1, col2 ORDER BY col1, col2) AS rn
FROM mytable
)
DELETE
FROM q
WHERE rn >= 2

看这里:
  • Deleting duplicates
  • 关于sql server 2008 删除重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5461369/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com