只用一條語句刪除重複資料 delete另類用法

2021-05-11 08:44:37 字數 443 閱讀 7077

--在sql2005下可以 ,sql2000不可以

create  table tb(id int,name varchar(4))

insert tb select 1,'aa'

union all select 1,'aa'

union all select 2,'bb'

union all select 3,'bb'

union all select 4,'cc'

union all select 1,'aa'

union all select 4,'cc'

delete a from

(select id,name,rn=row_number() over(partition by id,name order by id) from tb) a where rn>1

select * from tb

Oracle 刪除重複資料只留一條

1 查詢表中多餘的重覆記錄,重覆記錄是根據單個字段 id 來判斷 select from 表 where id in select id from 表 group byid h ing count id 1 2 刪除表中多餘的重覆記錄,重覆記錄是根據單個字段 id 來判斷,只留有rowid最小的記錄...

mysql刪除單列重複資料並保留一條

自己剛好有這種需求,又不是很熟悉sql果斷去查一下 mysql mysql刪除重覆記錄並且只保留一條.自己動手測試一下,順帶說一下mysql workbench,懶得去找xx破解的話還是可以的,感覺夠用了。create table ta test2 idnew table varchar 45 no...

批量刪除表中的重複資料,僅保留一條不重複資料

我們在sql資料中,經常遇到乙個表中有許多的重複資料,如何才能刪除那些重複的資料,僅保留一條不重複的資料呢?一般情況我們會分四步來處理 1 原來的表結構 2create table dict xh3 4 id int notnull 5 xh varchar 50 not null6 78 1.新建...