删除表中的重复值 [英] Remove duplicate values in table

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

问题描述

大家好,
如何从表中删除重复的值?

解决方案

尝试一下.

临时

 选择 * 

一起使用作为
(
    选择 row_number()上(分区  by  id,更新日期顺序  by  id) as  rn
    来自临时
)
删除 删除其中 rn>  1 

选择 * 临时




输出:
3 2012-05-24 10:22:08.523
3 2012-05-24 10:22:08.523


3 2012-05-24 10:22:08.523


此处建议一种方法: ^ ]-但是请阅读消息,因为它们建议其他消息.

Hi to all,
how can I remove duplicate values from table?

解决方案

try this.


select * from temp;

with a as
(
    select row_number() over(partition by id,updateddate order by id) as rn
    from temp
)
delete from a where rn > 1

select * from temp




The output:
3 2012-05-24 10:22:08.523
3 2012-05-24 10:22:08.523


3 2012-05-24 10:22:08.523


There is a method suggested here: Remove Duplicate Rows from a Table in SQL Server[^] - but read the messages as they suggest some others.


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

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