如何删除SQL中非唯一行的重复行? [英] how to delete duplicate rows of non unique rows in SQL ?

查看:103
本文介绍了如何删除SQL中非唯一行的重复行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

如何在SQL中删除非唯一行的重复行?

我有3个重复的行,这些行不是唯一行

这是我在SQL中的表格

名称
````
xyz
xyz
只需删除前2行,保留第三行. xyz

在此先感谢

Naveen ...

hi all

how to delete duplicate rows of non unique rows in SQL ?

I have 3 duplicate rows which are non - unique rows

this is my table in SQL

Name
````
xyz
xyz
xyz`````Need to delete only first 2 rows ,Leave third row. xyz

Thanks in advance

Naveen...

推荐答案

将其完整地进行查询会有些复杂,请在此处查看详细的方法:
MSDN:如何从SQL Server中的表中删除重复的行 [
It will be a little complicated to make it full querywise, have a look at detailed way here:
MSDN: How to remove duplicate rows from a table in SQL Server[^]


Naveen
如果使用sqlserver2005,则可以尝试.

Naveen
If you use sqlserver2005,you can try it.

<pre lang="sql">WITH [CTE DUPLICATE] as
(SELECT RN=ROW_NUMBER() OVER (ORDER BY name)
FROM test
)
delete from [CTE DUPLICATE] where RN<3


这篇关于如何删除SQL中非唯一行的重复行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆